Refresh access and ID tokens using refresh token for React SPA

I have created a React SPA application with refresh token configured in the application. I am trying to refresh the access and ID tokens using refresh token. I would like to know the next steps to do so or a sample code.

Any help would be appreciated.

Thanks!

1 Like

If you’re using our React SDK, all you need to do is ensure that you have configured your application to request the offline_access scope, which will result in Okta returning back this refresh token. Our SDK will then handle the token renewals for you using the refresh token.

Hi @andrea. Thank you for the response. I am using Okta Sign-In Widget and have configured offline_access scope in the config file. I followed the documentation to call the /token endpoint and pass the refresh token to get a new set of tokens. I am unable to make the call from code as I am unable to capture the refresh_token. Am I missing something here?

Do you see a refresh_token being returned in the initial /token request? If you’re using our SDK, our LoginCallback component will store these in the TokenManager and handle the renewals for you, without needing to do it yourself.

Are you having to manually call /token yourself right now from the beginning, or is the SDK trying to handle that part and running into an issue during the renewal?

Hi @andrea. I am receiving the refresh_token through the /token endpoint and the tokens are automatically refreshed as per their lifetime set in the admin console.

Thank you for the help.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.