# OAuthInternetAccount

Auto-generated from the @jbrowse/mobx-state-tree model in the source — see the [developer guide](https://jbrowse.org/jb2/docs/developer_guide/) for concepts. Provided by the `authentication` plugin. [View source](https://github.com/GMOD/jbrowse-components/blob/main/plugins/authentication/src/OAuthModel/model.tsx).

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](../../config/oauthinternetaccount).

## Properties

| Member | Description |
| --- | --- |
| **type**<br><code>type: types.literal('OAuthInternetAccount')</code> |  |
| **configuration**<br><code>configuration: ConfigurationReference(configSchema)</code> |  |

## Getters

| Member | Description |
| --- | --- |
| **conf**<br><code>ConfigNodeProps&lt;…&gt; &amp; ConfigNodeActions &amp; ConfigNodeBrand&lt;ConfigurationSchemaType&lt;…&gt;&gt;</code> | The config typed off the concrete schema. `ConfigurationReference` erases `self.configuration` to `any` (the reference's MST instance brand doesn't carry the schema's slot definitions), so reads go through this getter to recover per-slot types and slot-name validation. |
| **authEndpoint**<br><code>string</code> |  |
| **tokenEndpoint**<br><code>string</code> |  |
| **needsPKCE**<br><code>boolean</code> |  |
| **clientId**<br><code>string</code> |  |
| **scopes**<br><code>string</code> |  |
| **state**<br><code>string</code> | OAuth state parameter: https://www.rfc-editor.org/rfc/rfc6749#section-4.1.1<br><br>Can override or extend if dynamic state is needed. |
| **responseType**<br><code>string</code> |  |
| **refreshTokenKey**<br><code>string</code> |  |
| **authFlowParams**<br><code>Record&lt;string, string&gt;</code> | Extra parameters to add to the authorization request. Empty here; a provider that needs one of its own overrides this. |

## Methods

| Member | Description |
| --- | --- |
| **retrieveRefreshToken**<br><code>() =&gt; string &#124; undefined</code> |  |

## Actions

| Member | Description |
| --- | --- |
| **storeRefreshToken**<br><code>(refreshToken: string) =&gt; void</code> |  |
| **removeRefreshToken**<br><code>() =&gt; void</code> |  |
| **postTokenGrant**<br><code>(grant: Record&lt;string, string&gt;, describeError: (response: Response) =&gt; Promise&lt;string&gt;) =&gt; Promise&lt;string&gt;</code> | 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, and OAuth 2 says so (RFC 6749 §4.1.3, §6). They differ in the grant's own parameters and in what a failure means, which is what stays at the call sites. |
| **exchangeAuthorizationForAccessToken**<br><code>(code: string, redirectUri: string, codeVerifier: string &#124; undefined) =&gt; Promise&lt;string&gt;</code> |  |
| **exchangeRefreshForAccessToken**<br><code>(refreshToken: string) =&gt; Promise&lt;string&gt;</code> |  |
| **validateTokenWithProbe**<br><code>(token: string, probe: (token: string) =&gt; Promise&lt;Response&gt;, describeError: (response: Response, reason?: string &#124; undefined) =&gt; Promise&lt;string&gt;) =&gt; Promise&lt;string&gt;</code> | Prove a token against the resource and, if that fails, refresh it once and prove the new one. Returns whichever token worked; throws if neither does. 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**<br><code>() =&gt; Promise&lt;string&gt;</code> | 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**<br><code>(resolve: (token: string) =&gt; void, reject: (error: Error) =&gt; void) =&gt; Promise&lt;void&gt;</code> |  |
| **validateToken**<br><code>(token: string, location: UriLocation) =&gt; Promise&lt;string&gt;</code> |  |

