Welcome to the new Box Support website. Check out all the details here on what’s changed.

How to Use an Updated Access Token in Content Explorer

Answered
New post

Comments

4 comments

  • cbetta

     how are you updating the access token? Have you tried explicitly removing the container and then reinitialize the explorer?

    0
    Comment actions Permalink
  • pingan00

     thanks for the suggestion.  Removing the container and reinitializing the explorer works, but it's undesirable for 2 reasons:

    • there is a visual flicker 
    • the navigation hierarchy is reset to the top level

    Is there really no way to update the token in place? This must be a common scenario, no? I'm browsing some files, I step away for lunch, I come back, bam - I get an error when I try to resume browsing.

     

    I did find these issues (#640#641), which ask the same question for Content Preview. I don't quite understand the final comment: "We decided to keep the interface for box-content-preview and make modifications to the interface at a higher level in box-ui-elements." It's referring to an undocumented updateToken method on Content Preview.

     

    0
    Comment actions Permalink
  • jstoffan

    Hi :

     

    The token value is passed to our API factory when ContentExplorer is instantiated; we currently don't provide a mechanism to update it afterward. However, rather than passing a token string, you could instead pass a function that returns a promise that resolves to a token string:

    const contentExplorer = new ContentExplorer();
    const tokenGenerator = function() {
        // Whatever logic is needed, so long as it returns a promise which ultimately resolves with a token string
    };
    
    contentExplorer.show(FOLDER_ID, tokenGenerator);

    You can find related documentation for the same concept in our box-content-preview library. Hope that helps.

    0
    Comment actions Permalink
  • pingan00

    That did the trick; thank you  

    0
    Comment actions Permalink

Please sign in to leave a comment.