-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Intermittent Undefined Token During Token Refresh with AWS Amplify in Angular App #14184
Comments
Hey, @reshmaissac 👋. We'll look into reproducing this on our side, but could you provide a little more sample code around the |
Hi @cwomack below is a sample code:
|
@reshmaissac, thank you for the code samples. Is the device going offline after the 1 hour point when you're experiencing this and getting the undefined token? Do you observe any failed fetch call to Cognito within the Network tab when this happens? If so, can you provide a screenshot of the error to give us a little more detail? |
Hi @cwomack, Thanks for the quick replys. The device maintains connectivity throughout. No failed fetch. On subsequent fetches after getting an undefined token, it works fine and token is present in the session. Suspect anything to do with a delay in getting the new session from amplify ? |
@reshmaissac, is this happening then with every single API call at that point and is highly reproducible or more of an edge case/hard to reproduce? We have tried on our side but haven't had any luck. If you could share that network request when it happens that would be helpful, but can you also try the following:
|
Hi @cwomack The issue is intermittent and hard to reproduce consistently. It seems to occur when the UI remains open for a long time without user activity. I have already been using AWS Amplify version "6.12.2". I will upgrade to "6.12.3" and monitor for reproduction. Could there be a scenario where fetchAuthSession briefly returns an incomplete session before completing the refresh? Will calling fetchAuthSession with forceRefresh = true helps? |
Hey @reshmaissac thanks for following up, re:
On other failure occasions |
Hey @reshmaissac, were you able to mitigate the issue by upgrading? |
Before opening, please confirm:
JavaScript Framework
Angular
Amplify APIs
Authentication
Amplify Version
v6
Amplify Categories
auth
Backend
None
Environment information
Describe the bug
I am encountering an issue where the idToken occasionally becomes undefined in my Angular app integrated with AWS Cognito using AWS Amplify. This issue is intermittent but often occurs when the UI remains open for a long time, potentially during token expiration or refresh events. Could be a scenario where fetching the token fails or doesn't provide updated session information.
AWS Cognito Configuration:
Refresh token expiration: 30 days
ID token expiration: [Default/Configured duration]
Auth setup: Amplify Auth with fetchAuthSession in AuthService class.
Is there a recommended way to avoid undefined tokens during such token refresh scenarios??
Expected behavior
When the token expires, AWS Amplify should seamlessly refresh the token and provide a valid idToken in the session object returned by fetchAuthSession().
Reproduction steps
Observed:
The session.tokens is undefined occasionally in below code in AuthService to fetch token from current session:
Code Snippet
// Put your code below this line.
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: