Requesting refresh-token

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!

Hi @rafakwolf

What is the tokenUrl value in both examples?

Hi @dragos, sorry :slight_smile:

It’s https://liferayclouddev.okta.com/oauth2/default/v1/token

Thanks

Hi @rafakwolf

Thanks for providing the link. I am not able to see any errors or why this would not work.
Can you please open a support ticket with us through a mail to developers@okta.com in order to have this issue further investigated?

Shouldnt the scope request also have offline_access ?

Hi @dragos, I did this already.
Hi @Govner, shouldn’t the request using Axios fail without offline_access?

Thanks guys

Any updates here guys?
Thanks