Skip to content

Documentation / react-auth / useOAuthTokens

Function: useOAuthTokens()

useOAuthTokens(callbacks?): UseOAuthTokens

Use this hook to retrieve the user's OAuth tokens after any subsequent OAuth Authorization flow. Ensure that this callback is mounted whenever your user undergoes a successful OAuth authorization flow to access the OAuth and Refresh tokens.

Parameters

callbacks?: Object

callbacks.onOAuthTokenGrant?: (oAuthTokens, o) => void

Callback that will execute when a user successfully authorizes an OAuth flow.

ParamOAuthTokens - the OAuth tokens returned from the OAuth provider:

Param {string} The OAuth provider type.

Param {string} The OAuth access token.

Param {number} (optional) The number of seconds until the OAuth access token expires.

Param {string} (optional) The OAuth refresh token.

Param {number} (optional) The number of seconds until the OAuth refresh token expires. if the refresh token is present and this field is undefined, it is assumed that the refresh token does not have an expiration date.

Param {string[]} (optional) The list of OAuth scopes the access token is approved for.

ParamUser (optional) The list of OAuth scopes the access token is approved for.

Returns

UseOAuthTokens

reauthorize.reauthorize UseOAuthTokens triggers the OAuth authorization fow for an existing account