Constructor
new PersistentSession(tokenInfo, tokenStoreopt, config, tokenManager)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
tokenInfo |
TokenInfo | A valid TokenInfo object. Will throw if improperly formatted. | |
tokenStore |
TokenStore |
<optional> |
A valid TokenStore object. Will throw if improperly formatted. |
config |
Config | The SDK configuration options | |
tokenManager |
TokenManager | The token manager |
- Source:
Methods
(private) _refreshTokens(optionsopt) → {Promise.<string>}
Attempts to refresh tokens for the client.
Will use the Box refresh token grant to complete the refresh. On refresh failure, we'll
check the token store for more recently updated tokens and load them if found. Otherwise
an error will be propagated.
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>
(private) _refreshTokens(optionsopt) → {Promise.<string>}
Attempts to refresh tokens for the client.
Will use the Box refresh token grant to complete the refresh. On refresh failure, we'll
check the token store for more recently updated tokens and load them if found. Otherwise
an error will be propagated.
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>
(private) _setTokenInfo(tokenInfo) → {void}
Sets all relevant token info for this client.
Parameters:
Name | Type | Description |
---|---|---|
tokenInfo |
TokenInfo | A valid TokenInfo object. |
- Source:
Returns:
- Type
- void
(private) _setTokenInfo(tokenInfo) → {void}
Sets all relevant token info for this client.
Parameters:
Name | Type | Description |
---|---|---|
tokenInfo |
TokenInfo | A valid TokenInfo object. |
- 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
|
- 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
|
- Source:
Returns:
- Type
- void
getAccessToken(optionsopt) → {Promise.<string>}
Returns the clients access token.
If tokens don't yet exist, first attempt to retrieve them.
If tokens are expired, first attempt to refresh them.
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>}
Returns the clients access token.
If tokens don't yet exist, first attempt to retrieve them.
If tokens are expired, first attempt to refresh them.
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>
handleExpiredTokensError(err) → {Promise.<Error>}
Handle an an "Expired Tokens" Error. If our tokens are expired, we need to clear the token
store (if present) before continuing.
Parameters:
Name | Type | Description |
---|---|---|
err |
Errors~ExpiredTokensError | An "expired tokens" error including information about the request/response. |
- Source:
Returns:
Promise resolving to an error. This will
usually be the original response error, but could an error from trying to access the
token store as well.
- Type
- Promise.<Error>
handleExpiredTokensError(err) → {Promise.<Error>}
Handle an an "Expired Tokens" Error. If our tokens are expired, we need to clear the token
store (if present) before continuing.
Parameters:
Name | Type | Description |
---|---|---|
err |
Errors~ExpiredTokensError | An "expired tokens" error including information about the request/response. |
- Source:
Returns:
Promise resolving to an error. This will
usually be the original response error, but could an error from trying to access the
token store as well.
- Type
- Promise.<Error>
revokeTokens(optionsopt) → {Promise}
Revokes the session's tokens. If the session has a refresh token we'll use that,
since it is more likely to be up to date. Otherwise, we'll revoke the accessToken.
Revoking either one will disable the other as well.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
TokenRequestOptions |
<optional> |
Sets optional behavior for the token grant |
- Source:
Returns:
Promise that resolves when the revoke succeeds
- Type
- Promise
revokeTokens(optionsopt) → {Promise}
Revokes the session's tokens. If the session has a refresh token we'll use that,
since it is more likely to be up to date. Otherwise, we'll revoke the accessToken.
Revoking either one will disable the other as well.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
TokenRequestOptions |
<optional> |
Sets optional behavior for the token grant |
- Source:
Returns:
Promise that resolves when the revoke succeeds
- Type
- Promise