# ReactNative - getCredentials returns undefined when a token is expired

**URL:** <https://community.auth0.com/t/reactnative-getcredentials-returns-undefined-when-a-token-is-expired/124438>\
**Category:** Get Help\
**Tags:** new-universal-login-experience, login-experience\
**Created:** [January 9, 2024, 6:08am UTC](https://community.auth0.com/t/reactnative-getcredentials-returns-undefined-when-a-token-is-expired/124438 "2024-01-09T06:08:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jakub.saleniuk](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jakub.saleniuk/32/53780_2.png) [@jakub.saleniuk](https://community.auth0.com/u/jakub.saleniuk)\
**Post date:** [January 9, 2024, 6:08am UTC](https://community.auth0.com/t/reactnative-getcredentials-returns-undefined-when-a-token-is-expired/124438/1 "2024-01-09T06:08:24Z")

</div>

Hi there,

I’m building a React Native app and I wanted to refresh expired access tokens using refresh tokens. I’ve configured everything in the Auth0 dashboard and I get a refresh token after authorization. The issue is when an access token expires and I call getCredentials method it returns undefined, but in fact the token is refreshed. To get a token I need to call the getCredentials method again. Not sure if that’s a desired behaviour. For now I just call it twice and it works, but it doesn’t look good. Does anyone else experience the same issue? Not sure if that’s related to React Native library: [react-native-auth0 - npm](https://www.npmjs.com/package/react-native-auth0) or Auth0 in general. Couldn’t find anything helpful in the internet so far.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [January 19, 2024, 11:52pm UTC](https://community.auth0.com/t/reactnative-getcredentials-returns-undefined-when-a-token-is-expired/124438/3 "2024-01-19T23:52:32Z")

</div>

Hey @jakub.saleniuk welcome to the community!

> [@jakub.saleniuk](#):
>
> The issue is when an access token expires and I call getCredentials method it returns undefined, but in fact the token is refreshed. To get a token I need to call the getCredentials method again. Not sure if that’s a desired behaviour.

Just to be clear, on the first call the refresh token is rotated (new refresh token) but there is no access token returned? On the 2nd call you do indeed get a new access token back as expected. FWIW it shouldn’t require 2 calls to getCredentials assuming a valid refresh token is available.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [February 2, 2024, 11:53pm UTC](https://community.auth0.com/t/reactnative-getcredentials-returns-undefined-when-a-token-is-expired/124438/4 "2024-02-02T23:53:18Z")

</div>

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