StormpathOAuthToken
stormpath.oauth
A service for managing OAuth tokens. It offers a simple interface for storing and reading tokens into a generic storage (backed by TokenStoreManager), as well as utility methods for getting specific components of the token - the access token, refresh token, token type, as well as the Authorization header constructed from the token.
It uses the token store type set in the provider, unless overrided via StormpathOAuthToken.setTokenStoreType.
Retrieves the access token from storage, relying on the token store for implementation. In case there of storage failure or there being no access token, the result is instead a rejected promise.
| Promise | Promise containing the access token, or a rejection in case of failure |
Retrieves the refresh token from storage, relying on the token store for implementation. In case there of storage failure or there being no refresh token, the result is instead a rejected promise.
| Promise | Promise containing the refresh token, or a rejection in case of failure |
Retrieves the OAuth token data object from storage, relying on its set token store for the loading implementation details. The result will use camel-cased keys, as noted in StormpathOAuthToken.setTokenResponse.
| Promise | A promise containing either the resolved token, or a rejection with a reason. |
Retrieves the token type from storage, relying on the token store for implementation. In case there of storage failure or there being no token type, the result is instead a rejected promise.
| Promise | Promise containing the token type, or a rejection in case of failure |
Removes the OAuth token from storage, relying on its set token store for the implementation details.
| Promise | A promise indicating whether the operation had succeeded |
Stores the OAuth token data object into storage, relying on its token store for the storage implementation details. It transforms the snake-cased keys returned from the API into camel-cased keys when storing the token.
| Param | Type | Details |
|---|---|---|
| token | Object | The OAuth authorization response returned by the API |
| Promise | A promise that is resolved or rejected when the storage attempt succeeds or fails |
Sets the name of the token store type that this token uses to store and load its data. See TokenStoreManager.getTokenStore for details.
| Param | Type | Details |
|---|---|---|
| tokenStoreType | String | The name of the token store type this token should use to record and read their data. |