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

Fix httpClient should not throw if user is disconnected #11

Merged
merged 1 commit into from
Dec 20, 2023
Merged

Conversation

slax57
Copy link
Contributor

@slax57 slax57 commented Dec 20, 2023

Problem

If the token cannot be acquired from the cache (e.g. because it is no longer valid or because the user is disconnected), calling auth0Client.getTokenSilently() in httpClient will throw an Error (e.g. a Login required error).

The problem is that this will block the actual request from firing, and it will not necessarily trigger a new login attempt since authProvider.checkError() won't throw in that case.

Solution

Catch any error thrown while calling auth0Client.getTokenSilently() in httpClient, and rely on the fact that the API will then be called without the Authorization header, which should return a 401 or 403 status code (if the endpoint is protected) which should activate authProvider.checkError().

@djhi djhi merged commit 6065d6e into main Dec 20, 2023
@djhi djhi deleted the fix-httpClient branch December 20, 2023 16:11
@djhi djhi added this to the 1.1.1 milestone Dec 20, 2023
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.

None yet

2 participants