new OAuth2Account(options)
Construct a OAuth2Account instance, that will handle fetching and refreshing access tokens.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
Members
accessToken
Setter for accessToken, also stores it in persistent storage.
accessToken
Getter for accessToken.
expiresIn
Getter for expiresIn.
expiresIn
Setter for expiresIn, stores it in persistent storage.
refreshToken
Getter for refreshToken.
refreshToken
Setter for refreshToken, also stores it in persistent storage.
Methods
destroy()
Method that will clean up event listeners and unsets storage settings.
getAccessTokens(code) → {Promise}
Method that performs a request to retrieve access tokens.
Parameters:
Name | Type | Description |
---|---|---|
code |
string | OAuth2 code |
Returns:
- Type
- Promise
getOAuth2Url() → {string}
Method that returns the OAuth2Url belonging to this OAuth2Account.
Returns:
- Type
- string
getStoreValues() → {Object}
Returns important values that should be stored persistently.
Returns:
- Type
- Object
refreshAccessTokens() → {Promise}
Method that performs a request that will refresh the access tokens.
Returns:
- Type
- Promise
setRefreshTokenTimeout(refreshTimeoutSeconds)
Method that sets a timeout for the next refresh of tokens.
Parameters:
Name | Type | Description |
---|---|---|
refreshTimeoutSeconds |
number | Timeout when tokens need to be refreshed in seconds |
setTokens(tokens)
Method that sets access token and refresh token and then emits the token event to update all listeners.
Parameters:
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tokens |
Object |
Properties
|