# Angular isAuthenticated state is lost on refresh

**URL:** <https://community.auth0.com/t/angular-isauthenticated-state-is-lost-on-refresh/82704>\
**Category:** Get Help\
**Tags:** authentication, angular, auth0\
**Created:** [May 1, 2022, 6:40pm UTC](https://community.auth0.com/t/angular-isauthenticated-state-is-lost-on-refresh/82704 "2022-05-01T18:40:20Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![austin-bmn](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/austin-bmn/32/34832_2.png) [@austin-bmn](https://community.auth0.com/u/austin-bmn)\
**Post date:** [May 1, 2022, 6:40pm UTC](https://community.auth0.com/t/angular-isauthenticated-state-is-lost-on-refresh/82704/1 "2022-05-01T18:40:20Z")

</div>

Hi there,

I have been working on developing an Angular front end to communicate with a .net 6 API. I have chosen Auth0 for my authentication framework. I have followed the Angular quickstart to get up and running with my application and it seems to be working really well. I was doing some testing recently though and found that when I refresh my browser (Chrome) I lose authentication. I can hit the “login” button that I’ve built on my front end, which is supposed to redirect me to Auth0’s login window, however it appears that the page simply refreshes after sending a code to Auth0’s authorize endpoint and I’m still logged out after the redirection is complete.

Occasionally if I navigate from a protected route (one that requires authentication) back to the root of my application, I will suddenly regain authenticated status.

I have researched a few articles and according to what I’ve read, I need to implement Refresh token rotation in order to solve this issue. I believe I’ve done so correctly however I still appear to be encountering the issue. Any help here is greatly appreciated.

Example of my Auth0 implementation from app.module.ts:

 ![image](https://global.discourse-cdn.com/auth0/original/3X/6/d/6d4bb2eb8d0fdb70201d23f670cd16622ac7a480.png)

Example of my Auth0 management dashboard (specifically refresh token rotation section):

 ![image](https://global.discourse-cdn.com/auth0/original/3X/d/5/d59f488f7af06d142ba47cc861c16a109b87d440.png)

- Which SDK this is regarding: auth0-angular
- SDK Version: 1.8.2
- Platform Version: Angular 13
- Code Snippets/Error Messages/Supporting Details/Screenshots:

---

<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:** [May 4, 2022, 5:46pm UTC](https://community.auth0.com/t/angular-isauthenticated-state-is-lost-on-refresh/82704/3 "2022-05-04T17:46:35Z")

</div>

Hi @austin-bmn,

Welcome to the Auth0 Community!

Are you setting `useRefreshTokens` to `true`? I see you are passing an env variable, but please confirm.

Otherwise, can you please tell us if you are successfully returned a refresh token after login?

---

<div class="post-metadata">

**Author:** ![austin-bmn](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/austin-bmn/32/34832_2.png) [@austin-bmn](https://community.auth0.com/u/austin-bmn)\
**Post date:** [May 5, 2022, 12:08am UTC](https://community.auth0.com/t/angular-isauthenticated-state-is-lost-on-refresh/82704/4 "2022-05-05T00:08:56Z")

</div>

Hi @dan.woda , thanks for the warm welcome.

Yes I’m setting useRefreshTokens to true, and it is persisting to my deployed environment. I have verified this through debugging the value.

How can I check if I am receiving the refresh token properly? I’m checking my local storage in my dev tools after logging in and I don’t see anything there.

Please let me know. Thanks,

Austin

---

<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:** [May 6, 2022, 6:03pm UTC](https://community.auth0.com/t/angular-isauthenticated-state-is-lost-on-refresh/82704/5 "2022-05-06T18:03:36Z")

</div>

@austin-bmn,

You can also inspect the request and response via DevTools _Network_ tab. You can look at the response from the `/token` endpoint.

If you are having trouble, feel free to DM me a [HAR](https://auth0.com/docs/troubleshoot/guides/generate-har-files) file and I will take a look.

---

<div class="post-metadata">

**Author:** ![austin-bmn](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/austin-bmn/32/34832_2.png) [@austin-bmn](https://community.auth0.com/u/austin-bmn)\
**Post date:** [May 11, 2022, 11:50pm UTC](https://community.auth0.com/t/angular-isauthenticated-state-is-lost-on-refresh/82704/6 "2022-05-11T23:50:32Z")

</div>

Thanks for the assistance Dan.

I’ve DM’d you the HAR file, and included a summary of the response here as well in case this is useful:

/token request: request to /oauth/token endpoint with Auth0-client and content type headers.

/token response: Valid access token in JWT format, along with scope, expiry and bearer token type.

---

<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:** [May 12, 2022, 3:35pm UTC](https://community.auth0.com/t/angular-isauthenticated-state-is-lost-on-refresh/82704/7 "2022-05-12T15:35:12Z")

</div>

Thanks for sending that over! It looks like you are successfully returned a refresh token. 👍

Can you give us some more information about your application? Did you follow the [Auth0 Angular SDK Quickstarts: Login](https://auth0.com/docs/quickstart/spa/angular/01-login) to set up your implementation? Otherwise can you please share some code snippets?

Additionally, it might be helpful to have a screencast of the behavior you are describing. Feel free to DM it if it contains any sensitive info or for privacy.

---

<div class="post-metadata">

**Author:** ![austin-bmn](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/austin-bmn/32/34832_2.png) [@austin-bmn](https://community.auth0.com/u/austin-bmn)\
**Post date:** [May 13, 2022, 12:16am UTC](https://community.auth0.com/t/angular-isauthenticated-state-is-lost-on-refresh/82704/8 "2022-05-13T00:16:52Z")

</div>

Hi Dan,

I followed the Auth0 Angular SDK quickstart to set my app up. I’ll send some code snippets and a screencast of the behavior over DM.

---

<div class="post-metadata">

**Author:** ![austin-bmn](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/austin-bmn/32/34832_2.png) [@austin-bmn](https://community.auth0.com/u/austin-bmn)\
**Post date:** [May 14, 2022, 4:53pm UTC](https://community.auth0.com/t/angular-isauthenticated-state-is-lost-on-refresh/82704/9 "2022-05-14T16:53:25Z")

</div>

Dan examined my app.module.ts file closely and discovered that there were essentially two declarations for the auth configuration in my AuthModule declaration. Removing the unnecessary declaration fixed the issue.

Thanks again @dan.woda !

---

<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:** [May 16, 2022, 4:26pm UTC](https://community.auth0.com/t/angular-isauthenticated-state-is-lost-on-refresh/82704/10 "2022-05-16T16:26:35Z")

</div>

Thanks for updating with a solution!

---

<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 28, 2022, 10:34pm UTC](https://community.auth0.com/t/angular-isauthenticated-state-is-lost-on-refresh/82704/11 "2022-06-28T22:34:14Z")

</div>


