Refresh Access Token

oauth2/refresh-token@1.0.1
Supported by 3 providers
GA
P
T

Get Access Token from Refresh Token

Issue a new access token based on previously issued refresh token for OAuth 2.0 compatible providers. Client authentication can be provided directly as input, or, if supported, set as provider parameter.

Input
Refresh Token
Client ID
Client Secret
Result
Access Token
Expires in (seconds)
Scopes
Token type
Refresh token

1.Choose a provider

2.Use GetAccessTokenFromRefreshToken with mock in your code

npm i @superfaceai/one-sdk
const { SuperfaceClient } = require('@superfaceai/one-sdk');

const sdk = new SuperfaceClient();

async function run() {
  // Load the profile
  const profile = await sdk.getProfile('oauth2/refresh-token@1.0.1');

  // Use the profile
  const result = await profile
    .getUseCase('GetAccessTokenFromRefreshToken')
    .perform({
      refreshToken: '',
      clientId: '',
      clientSecret: ''
    }, {
      provider: 'mock'
    });

  // Handle the result
  try {
    const data = result.unwrap();
    console.log(data);
  } catch (error) {
    console.error(error);
  }
}

run();

Structure details

Input (object)

refreshToken
The refresh token previously issued to the client.
clientId
Client authentication; may be also accepted as provider parameter.
clientSecret
Client authentication; may be also accepted as provider parameter.

Example

{
  "refreshToken": "",
  "clientId": "",
  "clientSecret": ""
}

Result (object)

accessToken
Newly issued access token
expiresIn
Duration of time the access token is granted for.
scopes
Authorized scopes for the issued access token.
tokenType
The type of token this is, usually "Bearer".
refreshToken
Provider may issue a new refresh token, invalidating the previously used refresh token

Example

{
  "accessToken": "",
  "expiresIn": 42,
  "scopes": [
    ""
  ],
  "tokenType": "",
  "refreshToken": ""
}

Implementation details

Provider
mock
Use case
GetAccessTokenFromRefreshToken
Author
@superface
Source
Verified