Class: AnonymousSession

AnonymousSession(config, tokenManager)

An Anonymous Box API Session. The Anonymous API Session holds a Client Credentials accessToken, which it returns to the client so that it may make calls on behalf of anonymous users. Anonymous tokens will be refreshed in the background if a request is made within the "stale buffer" (defaults to 10 minutes before the token is set to expire). If the token is also expired, all incoming requests will be held until a fresh token is retrieved.

Constructor

new AnonymousSession(config, tokenManager)

Parameters:
Name Type Description
config Config The SDK configuration options
tokenManager TokenManager The TokenManager
Source:

Methods

exchangeToken(scopes, resourceopt, optionsopt) → {Promise.<TokenInfo>}

Return the anonymous session token, since there is no need to downscope a token that does not have any associated user credentials.
Parameters:
Name Type Attributes Description
scopes string | Array.<string> The scope(s) requested for the new token
resource string <optional>
The absolute URL of an API resource to scope the new token to
options TokenRequestOptions <optional>
Sets optional behavior for the token grant
Source:
Returns:
Promise resolving to the new token info
Type
Promise.<TokenInfo>

getAccessToken(optionsopt) → {Promise.<string>}

Produces a valid, anonymous access token. Performs a refresh before returning if the current token is expired. If the current token is considered stale but still valid, return the current token but initiate a new refresh in the background.
Parameters:
Name Type Attributes Description
options TokenRequestOptions <optional>
Sets optional behavior for the token grant
Source:
Returns:
Promise resolving to the access token
Type
Promise.<string>

revokeTokens(optionsopt) → {Promise}

Revokes the anonymous token used by this anonymous session, and clears the saved tokenInfo.
Parameters:
Name Type Attributes Description
options TokenRequestOptions <optional>
Sets optional behavior for the token grant
Source:
Returns:
Promise resolving if the revoke succeeds
Type
Promise