Skip to content
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

feat(auth): Provide a clear message during getTokens that there are no valid tokens on device #3518

Merged
merged 2 commits into from
Jan 26, 2024

Conversation

tylerjroach
Copy link
Member

@tylerjroach tylerjroach commented Jan 26, 2024

Issue #, if available:
N/A

We received a report that it is difficult to detect why the token refresh process fails, and if it is recoverable or not. This information is critical for a customer to understand whether or not the customer should log the user out.

We were able to identify that when a customer saw Exception("No cached session.") and there was an exception attached, such as UnknownHostException, these errors should be transient.

However, there are cases where the user only sees Exception("No cached session.", null) which leaves further questions on whether or not it is due to an invalid token, or some other transient issue.

Description of changes:

getAuthenticationDetails documentation states: "Call out to the dev to get the credentials for a user.". We can't do this during refresh flow, however, if we see this message, we understand that the Cognito service has stated that the refresh token is no longer valid.

The customer will now see ``Exception("No cached session.", new CognitoNotAuthorizedException("No valid tokens on device."))` and be able to act on this information.

I've added logging in additional places that are not expected to be hit, such as getMFACode, to make sure that we always provide better descriptions on refresh failures.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@tylerjroach tylerjroach requested a review from a team as a code owner January 26, 2024 15:45
@tylerjroach tylerjroach merged commit 46fb3c3 into main Jan 26, 2024
1 of 2 checks passed
@tylerjroach tylerjroach deleted the tjroach/no-valid-token-exception branch January 26, 2024 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants