Skip to content

Instantly share code, notes, and snippets.

@alfonmga
Last active September 5, 2023 22:29
Show Gist options
  • Save alfonmga/9602085094651c03cd2e270da9b2e3f7 to your computer and use it in GitHub Desktop.
Save alfonmga/9602085094651c03cd2e270da9b2e3f7 to your computer and use it in GitHub Desktop.
Apollo refresh auth token link. It tries to refresh the user access token on the fly when API throws out an UNAUTHENTICATED error. If multiple requests fail at the same time, it queues them to re-try them later if we are able to get a new access token, otherwise we log out the user and redirect him to the login page.
@forrestwilkins
Copy link

I've been struggling to get my refresh token logic to work for multiple failed request for a couple days now, and this finally solved it for me. Thank you for sharing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment