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.
npm i @superfaceai/one-sdk
const { SuperfaceClient } = require('@superfaceai/one-sdk');
// You can manage tokens here: https://superface.ai/insights
const sdk = new SuperfaceClient({ sdkAuthToken: '<< Login to get your token >>' });
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();
{
"refreshToken": "",
"clientId": "",
"clientSecret": ""
}
{
"accessToken": "",
"expiresIn": 42,
"scopes": [
""
],
"tokenType": "",
"refreshToken": ""
}