# Auth0-react 'LoginRequired' when trying to call getAccessTokenSilently

**URL:** <https://community.auth0.com/t/auth0-react-loginrequired-when-trying-to-call-getaccesstokensilently/109648>\
**Category:** Get Help\
**Tags:** users, management-api\
**Created:** [June 21, 2023, 7:08am UTC](https://community.auth0.com/t/auth0-react-loginrequired-when-trying-to-call-getaccesstokensilently/109648 "2023-06-21T07:08:43Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![azns](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/azns/32/59717_2.png) [@azns](https://community.auth0.com/u/azns)\
**Post date:** [June 21, 2023, 7:08am UTC](https://community.auth0.com/t/auth0-react-loginrequired-when-trying-to-call-getaccesstokensilently/109648/1 "2023-06-21T07:08:44Z")

</div>

I have setup a Typescript react app using the tutorial of auth0-react package.

My AuthenticationGuard class correctly redirects the user to login.

However, when they login:

1. If they refresh the page the browser is redirected to auth0 /authorize then back to my app without me having configured that anywhere
2. If I call `getAccessTokenSilently` I get the same redirect as above and I can see that token request fails with `login_required` error.

Is there some documentation on why I am getting these redirects and ‘login\_required’

---

<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:** [June 23, 2023, 12:18pm UTC](https://community.auth0.com/t/auth0-react-loginrequired-when-trying-to-call-getaccesstokensilently/109648/3 "2023-06-23T12:18:03Z")

</div>

Hi @azns,

Welcome to the Auth0 Community!

Is there any more info in the login required error?

When the applications does a `getTokenSilently`, it uses an existing session to renew the access token. The error indicates that the existing session doesn’t exist, is expired, etc.

This FAQ could be helpful: [Why is authentication lost after refreshing my single page application?](https://community.auth0.com/t/why-is-authentication-lost-after-refreshing-my-single-page-application/56276)

---

<div class="post-metadata">

**Author:** ![azns](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/azns/32/59717_2.png) [@azns](https://community.auth0.com/u/azns)\
**Post date:** [June 26, 2023, 3:07am UTC](https://community.auth0.com/t/auth0-react-loginrequired-when-trying-to-call-getaccesstokensilently/109648/4 "2023-06-26T03:07:45Z")

</div>

No.

It seems to work in Chrome only; in Firefox and Brave I am getting to my SPA, it either prompts user to login or makes a call to `authorize` and it gets id\_token and access\_token. But when in my code I call `getAccessTokenSilently` I am simply getting `login_required`.

I tried working over SSL (I am still developing locally, so my app is at [http://localhost:3000](http://localhost:3000)) but that made no difference.

---

<div class="post-metadata">

**Author:** ![azns](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/azns/32/59717_2.png) [@azns](https://community.auth0.com/u/azns)\
**Post date:** [June 26, 2023, 3:13am UTC](https://community.auth0.com/t/auth0-react-loginrequired-when-trying-to-call-getaccesstokensilently/109648/5 "2023-06-26T03:13:44Z")

</div>

Actually it seems that I have worked it out.

In Firefox and Brave this only works if I provide the audience to the `Auth0Provider`. I can’t use adaptive audience when calling `getAccessTokenSilently` it simply doesn’t work.

This is pretty odd and what are we supposed to do if we have multiple APIs we want to call?

---

<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:** [June 26, 2023, 1:13pm UTC](https://community.auth0.com/t/auth0-react-loginrequired-when-trying-to-call-getaccesstokensilently/109648/6 "2023-06-26T13:13:17Z")

</div>

Have you tried using refresh token rotation? Here’s another thread with a similar problem statement.

[https://community.auth0.com/t/auth0-react-sdk-getaccesstokensilently-returns-error-login-required-in-private-browser/82781/3](https://community.auth0.com/t/auth0-react-sdk-getaccesstokensilently-returns-error-login-required-in-private-browser/82781/3)

Additionally, localhost can sometime’s cause a “consent required” error you may see.

---

<div class="post-metadata">

**Author:** ![azns](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/azns/32/59717_2.png) [@azns](https://community.auth0.com/u/azns)\
**Post date:** [June 26, 2023, 11:28pm UTC](https://community.auth0.com/t/auth0-react-loginrequired-when-trying-to-call-getaccesstokensilently/109648/7 "2023-06-26T23:28:39Z")

</div>

@dan.woda I’d love to `use refresh token rotation` if I found anywhere how to enable it. I checked the toggle forever ago but it doesn’t seem to have any effect. From the requests in the browser I can see that it’s the token is returned in response to `authorization_code`.

---

<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:** [June 27, 2023, 11:56am UTC](https://community.auth0.com/t/auth0-react-loginrequired-when-trying-to-call-getaccesstokensilently/109648/8 "2023-06-27T11:56:11Z")

</div>

The doc for it is right here: [Configure Refresh Token Rotation](https://auth0.com/docs/secure/tokens/refresh-tokens/configure-refresh-token-rotation)

Please let me know if you have any questions.

---

<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:** [July 26, 2023, 3:20pm UTC](https://community.auth0.com/t/auth0-react-loginrequired-when-trying-to-call-getaccesstokensilently/109648/9 "2023-07-26T15:20:52Z")

</div>

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