Class: BasicSession

BasicSession(accessToken, tokenManager)

A BasicSession holds only a single accessToken. It has no idea how to authenticate, refresh, or persist its token information. When that token expires, the session and any clients using it will become useless. Basic API Session is the most simple API Session to use, which makes it a good choice for simple applications, developers who are just getting started, and applications that wish to manage tokens themselves.

Constructor

new BasicSession(accessToken, tokenManager)

Parameters:
Name Type Description
accessToken string The existing access token for a user
tokenManager TokenManager The token manager
Source:

Methods

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

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
actor ActorParams <optional>
Optional actor parameters for creating annotator tokens
Source:
Returns:
Promise resolving to the new token info
Type
Promise.<TokenInfo>

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

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
actor ActorParams <optional>
Optional actor parameters for creating annotator tokens
Source:
Returns:
Promise resolving to the new token info
Type
Promise.<TokenInfo>

getAccessToken() → {Promise.<string>}

Returns the clients access token. BasicSession never returns an error, since it doesn't know the status of its own token.
Source:
Returns:
Promise resolving to the access token
Type
Promise.<string>

getAccessToken() → {Promise.<string>}

Returns the clients access token. BasicSession never returns an error, since it doesn't know the status of its own token.
Source:
Returns:
Promise resolving to the access token
Type
Promise.<string>

revokeTokens(optionsopt) → {Promise}

Revokes the session's access token.
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 session's access token.
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