OAuthInternetAccount
Auto-generated from the @jbrowse/mobx-state-tree model in the source — see the developer guide for concepts. Provided by the authentication plugin. View source.
Gets an OAuth 2.0 access token from the provider's login window, and renews
it with a refresh token kept in localStorage.
The configuration slots for this model are documented on its config schema page.
Properties
| Member | Description |
|---|---|
typetype: types.literal('OAuthInternetAccount') | |
configurationconfiguration: ConfigurationReference(configSchema) |
Getters
| Member | Description |
|---|---|
confOAuthInternetAccountConfig | The config typed off the concrete schema. ConfigurationReference erases self.configuration to any (the reference's MST instance brand doesn't include the schema's slot definitions), so reads go through this getter to recover per-slot types and slot-name validation. |
authEndpointstring | |
tokenEndpointstring | |
needsPKCEboolean | |
clientIdstring | |
scopesstring | |
responseTypestring | |
refreshTokenKeystring | |
authFlowParamsRecord<string, string> | Extra parameters to add to the authorization request. Empty here; a provider that needs extra parameters overrides this. |
Methods
| Member | Description |
|---|---|
retrieveRefreshToken() => string | undefined |
Actions
| Member | Description |
|---|---|
storeRefreshToken(refreshToken: string) => void | |
removeRefreshToken() => void | |
| postTokenGrant | POST a grant to the token endpoint and read the access token out of the answer. Both grants this account makes — trading the authorization code on the way in, trading the refresh token when the access token expires — are the same form-encoded request to the same endpoint answered by the same body, as OAuth 2 specifies (RFC 6749 §4.1.3, §6). They differ in the grant's parameters and in what a failure means, which is what stays at the call sites. |
exchangeRefreshForAccessToken(refreshToken: string) => Promise<string> | |
| validateTokenWithProbe | Prove a token against the resource and, if the resource answers 401, refresh it once and prove the new one. Returns whichever token worked; throws if neither does, or if the resource fails for any other reason. Every OAuth account validates this way and they differ only in what a probe is — a HEAD of the resource here, a metadata call for Dropbox and Google Drive. |
getTokenViaAuthFlow() => Promise<string> | Opens the provider's auth page and returns a promise for the resulting token. For Electron, drives the flow directly via IPC; for web, opens a popup and waits for the redirect message. |
| getTokenFromUser | |
validateToken(token: string, location: UriLocation) => Promise<string> |