# Application is getting redirected when calling getAccessTokenSilently() to get a new token when we have an active token

**URL:** <https://community.auth0.com/t/application-is-getting-redirected-when-calling-getaccesstokensilently-to-get-a-new-token-when-we-have-an-active-token/123385>\
**Category:** Get Help\
**Tags:** login-prompt-new-experience, login-experience\
**Created:** [December 19, 2023, 5:29pm UTC](https://community.auth0.com/t/application-is-getting-redirected-when-calling-getaccesstokensilently-to-get-a-new-token-when-we-have-an-active-token/123385 "2023-12-19T17:29:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![karan.udawat](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/karan.udawat/32/53382_2.png) [@karan.udawat](https://community.auth0.com/u/karan.udawat)\
**Post date:** [December 19, 2023, 5:29pm UTC](https://community.auth0.com/t/application-is-getting-redirected-when-calling-getaccesstokensilently-to-get-a-new-token-when-we-have-an-active-token/123385/1 "2023-12-19T17:29:22Z")

</div>

In my application we are using React SDK to authenticate a user. Our token expiry is of 60 mins and we have a requirement to refresh the token before 60 mins to get a new token for other subsequent API calls. For this we are calling the getAccessTokenSilently({detailedResponse: true, cacheMode: ‘off’}). “cacheMode : ‘off’” calls the token API and we get a new token. The issue which we are facing is that when we are calling the token API again with cacheMode: off the application reload automatically and we are re-directed to home screen. All the unsaved changes are lost. With cacheMode: ‘on/cache-only’ we get the same token again hence no APi call and hence no refresh but we get the same token which is not required. Any leads on this?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [December 22, 2023, 7:09pm UTC](https://community.auth0.com/t/application-is-getting-redirected-when-calling-getaccesstokensilently-to-get-a-new-token-when-we-have-an-active-token/123385/3 "2023-12-22T19:09:43Z")

</div>

Hi @karan.udawat,

Welcome to the Auth0 Community!

What are you seeing in response to the request to get the token silently? Is the request failing and requiring a login?

---

<div class="post-metadata">

**Author:** ![karan.udawat](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/karan.udawat/32/53382_2.png) [@karan.udawat](https://community.auth0.com/u/karan.udawat)\
**Post date:** [December 22, 2023, 7:46pm UTC](https://community.auth0.com/t/application-is-getting-redirected-when-calling-getaccesstokensilently-to-get-a-new-token-when-we-have-an-active-token/123385/4 "2023-12-22T19:46:30Z")

</div>

@dan.woda i am getting the sucess response with new access token and ID token. It also does not require a login. But the issue is there is a redirect\_uri parameter going with the token API call(I have tried overriding it with empty string also in getAccessTokenSilently() arguments) with is making the application to reload.

Payload-

 ![Screenshot 2023-12-23 at 1.10.49 AM](https://global.discourse-cdn.com/auth0/original/3X/6/0/60d968f7d379271e69fcac73e31ab4a751b9a5f7.png)

Response -

 ![Screenshot 2023-12-23 at 1.14.43 AM](https://global.discourse-cdn.com/auth0/original/3X/2/3/233e096f8defeb29fb82459802eb0ca22744ef71.png)

Also, as per the documents if we make useRefreshToken= true the token will get reloaded after the token is expired but it is not happening currently. I am using @auth0/auth0-react": “^2.2.3” package

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [January 2, 2024, 7:04pm UTC](https://community.auth0.com/t/application-is-getting-redirected-when-calling-getaccesstokensilently-to-get-a-new-token-when-we-have-an-active-token/123385/5 "2024-01-02T19:04:49Z")

</div>

Thanks for the additional info.

I set up a test app to try and reproduce this issue. I can’t reproduce the issue with reloading if I use refresh tokens and `getAccessTokenSilently({detailedResponse: true, cacheMode: ‘off’})`.

In my test app, I get the token silently in the background and stay on the same page. I used the [Auth0 React SDK Quickstarts: Call an API](https://auth0.com/docs/quickstart/spa/react/02-calling-an-api) code, added `useRefreshTokens: true` to the provider, and `{detailedResponse: true, cacheMode: ‘off’}` to the call to `getAccessTokenSilently`.

Could you please share your provider setup? Omit sensitive data please.

---

<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:** [January 19, 2024, 4:00pm UTC](https://community.auth0.com/t/application-is-getting-redirected-when-calling-getaccesstokensilently-to-get-a-new-token-when-we-have-an-active-token/123385/6 "2024-01-19T16:00:42Z")

</div>

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