Hi, I’m trying to get a refresh token using authorization-code
If I use the Axios library, like this:
const {clientId, clientSecret, tokenUrl, redirectUri} = myConfigs;
const config = {
headers: {
'Accept': 'application/json',
'Content-Type': 'application/x-www-form-urlencoded',
},
};
const body = {
client_id: clientId,
client_secret: clientSecret,
grant_type: 'authorization_code',
redirect_uri: redirectUri,
scope: 'openid profile',
code,
};
const {data} = await axios.post(tokenUrl, qs.stringify(body), config);
return data;
…everything works fine, but, if I use okta nodejs sdk, like this:
const {clientId, clientSecret, tokenUrl, redirectUri} = myConfigs;
const body = {
client_id: clientId,
client_secret: clientSecret,
grant_type: 'authorization_code',
redirect_uri: redirectUri,
scope: 'openid profile',
code,
};
const request = {
body: qs.stringify(body),
headers: {
'Accept': 'application/json',
'Content-Type': 'application/x-www-form-urlencoded',
},
};
return await this.sdk.http.post(tokenUrl, request);
I’m facing the error OktaApiError: Okta HTTP 401 undefined
And I’d like to use the Okta SDK, so I can use the executor options like retries and timeout.
can you guys help me?
Thanks!