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

[Auth-Graphql] How to re-request an operation with new headers (refresh token)? #164

Open
iamnabink opened this issue Feb 22, 2024 · 0 comments

Comments

@iamnabink
Copy link

iamnabink commented Feb 22, 2024

Hi, I am trying to use your package to build an personal project (GraphQL) and finding hard to implement a refresh process. Using Dio I could block the client so all the subsequence requests goes to a queue (using Queuedinterceptor), refresh and then queue is processed. Using your package, do I need to implement something like that by myself?
Right now I am using AuthLink which is in your case passing by custom class GraphQLToken :

GraphQLToken(builder: () async {
       final token = await getAccessToken();
       return `Bearer $token`
    },
  );

Unfortunately currently for the workaround, I have updated the API to return an expires_at time stamp. So, I can check to see if the token is expired before setting the header. If it is, then refresh the token, attach it, and then make the request.

It's not ideal, since tokens can expire for other reasons (like token expiring at the time of request and response is 401), so a true solution using the stream would definitely be preferable. Thanks in advance.

@iamnabink iamnabink changed the title [Auth] How to re-request an operation with new headers (refresh token)? [Auth-Graphql] How to re-request an operation with new headers (refresh token)? Feb 22, 2024
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

No branches or pull requests

1 participant