# Refresh tokens - okta-react-native

**URL:** <https://devforum.okta.com/t/refresh-tokens-okta-react-native/8586>\
**Category:** Questions\
**Created:** [March 24, 2020, 4:36pm UTC](https://devforum.okta.com/t/refresh-tokens-okta-react-native/8586 "2020-03-24T16:36:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![offensivelybad](https://avatars.discourse-cdn.com/v4/letter/o/cc9497/32.png) [@offensivelybad](https://devforum.okta.com/u/offensivelybad)\
**Post date:** [March 24, 2020, 4:36pm UTC](https://devforum.okta.com/t/refresh-tokens-okta-react-native/8586/1 "2020-03-24T16:36:08Z")

</div>

I am using a custom sign-in with a react-native app, similar to the example provided by Okta here: [https://github.com/okta/samples-js-react-native/tree/master/custom-sign-in](https://github.com/okta/samples-js-react-native/tree/master/custom-sign-in)

As you can see in `LoginScreen.js`, it is using the `signIn` method from okta-auth-js library to get a `sessionToken`, and then calling the `authenticate` method from okta-react-native SDK to get the `accessToken`.

This all works fine for me, but I’m unsure of how to refresh the `accessToken` manually. There’s a method in okta-react-native called `refreshTokens` but it is throwing an error when called: `Error: Error fetching fresh tokens: Unable to refresh expired token without a refresh token.`

I do not see a way to get a `refreshToken` in the documentation for neither okta-auth-js nor okta-react-native. I need to refresh the `accessToken` every time the user makes a request to the server. This is how my app works currently, and I’m trying to migrate to Okta with minimal impact to the app flow.

I’m able to use this flow in a React web app by calling `authClient.tokenManager.renew('accessToken')` but this does not work in a react-native application.

Can someone please advise how I can refresh the tokens?

PS. I do not want to use the webview modal login that Okta provides with the `signIn` method, as it is very disruptive to my app flow.

---

<div class="post-metadata">

**Author:** ![phi1ipp](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@phi1ipp](https://devforum.okta.com/u/phi1ipp)\
**Post date:** [March 25, 2020, 1:30am UTC](https://devforum.okta.com/t/refresh-tokens-okta-react-native/8586/2 "2020-03-25T01:30:35Z")

</div>

silly question, but does your application configured to support refresh tokens? are you requesting the offline scope to get the refresh token?

---

<div class="post-metadata">

**Author:** ![offensivelybad](https://avatars.discourse-cdn.com/v4/letter/o/cc9497/32.png) [@offensivelybad](https://devforum.okta.com/u/offensivelybad)\
**Post date:** [March 25, 2020, 7:07pm UTC](https://devforum.okta.com/t/refresh-tokens-okta-react-native/8586/3 "2020-03-25T19:07:07Z")

</div>

Thank you. Looks like that was the issue. I did not have access to the config but got an admin to check off that box. I can now call `refreshTokens()` successfully.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/oktadev/original/1X/589c4c5f80de422d01f47cee7185a7fb8227835c.png) [@system](https://devforum.okta.com/u/system)\
**Post date:** [January 23, 2024, 10:58pm UTC](https://devforum.okta.com/t/refresh-tokens-okta-react-native/8586/4 "2024-01-23T22:58:25Z")

</div>

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