refreshAuthToken()
function refreshAuthToken(args: RefreshTokenRequestArgs, options?: AuthOptions): Promise<AuthTokenResponse>;
Exchanges a refresh token for a new access token using the OAuth2
refresh_token grant.
Only relevant for OAuth apps that have refresh tokens enabled (the default for
new apps). Apps without them never receive a refreshToken from
getAuthToken, so they have nothing to pass here — their access tokens
are long-lived instead.
Omit clientSecret for public clients registered with
tokenEndpointAuthMethod: 'none'.
Parameters
| Parameter | Type |
|---|---|
args | RefreshTokenRequestArgs |
options? | AuthOptions |
Returns
Promise<AuthTokenResponse>
The refreshed token. The server rotates the refresh token, so the
response carries a new refreshToken — persist it in place of the old one.
Example
const { accessToken, refreshToken } = await refreshAuthToken({
clientId: 'your-client-id',
clientSecret: 'your-client-secret',
refreshToken: storedRefreshToken,
})
Throws
TodoistRequestError If the refresh fails