Class: CCGSession

CCGSession(config, tokenManager)

The Client Credentials Grant Box API Session. The Client Credentials Grant API Session holds a Client Credentials accessToken, which it returns to the client so that it may make calls on behalf of service account or specified users. 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 CCGSession(config, tokenManager)

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

Methods

exchangeToken(scopes, resourceopt, optionsopt) → {void}

Exchange the client access token for one with lower scope
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 Object <optional>
Optional parameters
Properties
Name Type Attributes Description
tokenRequestOptions TokenRequestOptions <optional>
Sets optional behavior for the token grant
Source:
Returns:
Type
void

exchangeToken(scopes, resourceopt, optionsopt) → {void}

Exchange the client access token for one with lower scope
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 Object <optional>
Optional parameters
Properties
Name Type Attributes Description
tokenRequestOptions TokenRequestOptions <optional>
Sets optional behavior for the token grant
Source:
Returns:
Type
void

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>

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

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