# Refresh tokens and getAccessTokenSilently behaviour

**URL:** <https://community.auth0.com/t/refresh-tokens-and-getaccesstokensilently-behaviour/185292>\
**Category:** Get Help\
**Tags:** rotating-refresh-tokens, sessions\
**Created:** [April 10, 2025, 12:30pm UTC](https://community.auth0.com/t/refresh-tokens-and-getaccesstokensilently-behaviour/185292 "2025-04-10T12:30:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![miguel.rosa](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/miguel.rosa/32/60019_2.png) [@miguel.rosa](https://community.auth0.com/u/miguel.rosa)\
**Post date:** [April 10, 2025, 12:30pm UTC](https://community.auth0.com/t/refresh-tokens-and-getaccesstokensilently-behaviour/185292/1 "2025-04-10T12:30:10Z")

</div>

Hi,

I’ve been searching and reading and there is something I’m missing out.  
I understand that because of browsers ITP technology simply calling the getAccessTokenSilently() fails. And I see in the logs the following:

- Success Login Successful login
- Failed Silent Auth Login required

The error makes sense. But how do we see a login immediately afterwards? And in my webpage I don’t get logged out or anything, I simply get a new token even with the error and the “login required”.

After reading and finding out about ITP I implemented refresh tokens which makes the error go away. But my question is, how does it work even without a refresh token despite the error ?

And, a couple of months ago I had a similar question where I was indicated to look into refresh tokens. My goal is to avoid users having to login after a page refresh, which I can do even without the refresh token, because (again) the getAccessTokenSilently() fails in the logs but still gets me a new token. Is there a way to reuse tokens while they are still valid and avoiding the localstorage option? getAccessTokenSilently() gets me a new token everytime with or without refresh tokens.

Best Regards

---

<div class="post-metadata">

**Author:** ![nik.baleca](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nik.baleca/32/68749_2.png) [@nik.baleca](https://community.auth0.com/u/nik.baleca)\
**Post date:** [April 11, 2025, 8:32pm UTC](https://community.auth0.com/t/refresh-tokens-and-getaccesstokensilently-behaviour/185292/3 "2025-04-11T20:32:21Z")

</div>

Hi @miguel.rosa

Welcome back to the Auth0 Community!

I am sorry about the delayed response to your inquiry!

As mentioned in the Github [documentation](https://auth0.github.io/auth0-react/interfaces/Auth0ContextInterface.html#getAccessTokenSilently) for Auth0 React:

> If there’s a valid token stored, return it. Otherwise, opens an iframe with the `/authorize` URL using the parameters provided as arguments. Random and secure `state` and `nonce` parameters will be auto-generated. If the response is successful, results will be valid according to their expiration times.
> 
> If refresh tokens are used, the token endpoint is called directly with the ‘refresh\_token’ grant. If no refresh token is available to make this call, the SDK will only fall back to using an iframe to the ‘/authorize’ URL if the `useRefreshTokensFallback` setting has been set to `true`. By default this setting is `false`.

If you are using something different than React, please let me know!

Otherwise, as mentioned above, the `getTokenSilently()` function will return a token if the user’s Auth0 session is still valid regardless if refresh tokens are used or not.  
The `Failed Silent Auth` might be thrown by something else in your application. Are you sure that the error is being thrown by `getAccessTokenSilently()` and not by something else?

Also, does the user get redirected when trying to fetch the token or do they get directly logged in? If that is the case, the application might not detect that the user has a valid session, throws the error, redirects to the `/authorize` endpoints, they have a valid session and get redirected back with the token.

If you have any other questions, let me know!

Kind Regards,  
Nik

---

<div class="post-metadata">

**Author:** ![miguel.rosa](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/miguel.rosa/32/60019_2.png) [@miguel.rosa](https://community.auth0.com/u/miguel.rosa)\
**Post date:** [April 18, 2025, 2:47pm UTC](https://community.auth0.com/t/refresh-tokens-and-getaccesstokensilently-behaviour/185292/4 "2025-04-18T14:47:39Z")

</div>

Thanks for your answer

After some research on my side I can say that the Failed Silent Auth is not being thrown by getAccessTokenSilently(). It looks like it throws after calling loginWithRedirect(), but if I just add useRefreshTokens={true} to the Auth0Provider the Failed Silent Auth is not thrown anymore.

Our flow is something like if isAuthenticated is false then loginWithRedirect() and after that we call the getAccessTokenSilently()  
The login counter for the user in the dashboard stays the same so I assume the application detected a valid session, therefore I would expect the getAccessTokenSilently() to return the same token if not expired, or did I misunderstand ?

We are using react.

Best regards,  
Miguel

---

<div class="post-metadata">

**Author:** ![nik.baleca](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nik.baleca/32/68749_2.png) [@nik.baleca](https://community.auth0.com/u/nik.baleca)\
**Post date:** [April 18, 2025, 6:56pm UTC](https://community.auth0.com/t/refresh-tokens-and-getaccesstokensilently-behaviour/185292/5 "2025-04-18T18:56:32Z")

</div>

Hi again.

Indeed, `getAccessTokenSilently()` should return a valid token if there is one present. Meaning that, in your use case, if `isAuthenticated()` is `false`, the user will be redirected to the` /authorize` endpoint in order to authenticate. If `getAccessTokenSilently()` is called after that, it should return the same token. If the user is not authenticated and `getAccessTokenSilently()` is called, they should be redirected to `/authorize` call and throw the `Failed Silent Auth` error.

If I can help with anything else, let me know!

Kind Regards,  
Nik

---

<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:** [May 2, 2025, 6:57pm UTC](https://community.auth0.com/t/refresh-tokens-and-getaccesstokensilently-behaviour/185292/6 "2025-05-02T18:57:24Z")

</div>

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