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

Is there a way to use axios interceptors to force a token refresh using this library? #1356

Open
5 tasks done
StijnKlarenbeek opened this issue Jun 27, 2023 · 5 comments
Open
5 tasks done
Assignees
Labels
question Further information is requested wontfix This will not be worked on

Comments

@StijnKlarenbeek
Copy link

StijnKlarenbeek commented Jun 27, 2023

Prerequisites:

Please answer the following questions for yourself before asking questions.

  • This is question only ❓
  • I am running the latest version
  • I checked the documentation and found no answer
  • I checked to make sure that this is not already asked
  • I'm asking the question in the correct repository

Describe the question
I would like to know whether or not it is possible to use axios interceptors to force the update of a refresh token using this library. Currently the auth provider is not sufficient for what's needed as we simply don't know when the last time the is that a user logged in.

License

Apache-2.0 © React Auth Kit

@StijnKlarenbeek StijnKlarenbeek added the question Further information is requested label Jun 27, 2023
@milly-code
Copy link

Hi @StijnKlarenbeek
Has this been resolved? If not, can you clarify for me please. Are you trying to force a refresh of the auth token that is for the user session?

if so, I may have a solution that worked for me.

@zukilover
Copy link

@milly-code It'd be great if you could share your idea.

I assume force refresh is done by simulating a re-sign in step (signIn()).
I've noticed there is a syncTokens method that is triggered every change of the authState:

syncTokens(authState: AuthKitStateInterface): void {
if (authState.auth) {
if (this.isUsingRefreshToken && authState.refresh) {
this.setToken(
authState.auth.token,
authState.auth.type,
authState.refresh.token,
authState.refresh.expiresAt,
authState.auth.expiresAt,
authState.userState,
);
} else {
this.setToken(
authState.auth.token,
authState.auth.type,
null,
null,
authState.auth.expiresAt,
authState.userState,
);
}
} else {
this.removeToken();
}
}

Copy link

stale bot commented Dec 15, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Dec 15, 2023
@darkmatter18
Copy link
Member

I will create the next plugin by the end of January. OSS's contribution will be appreciated.

@darkmatter18 darkmatter18 self-assigned this Jan 9, 2024
@darkmatter18 darkmatter18 removed the wontfix This will not be worked on label Jan 9, 2024
Copy link

stale bot commented Mar 17, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested wontfix This will not be worked on
Projects
Status: Todo
Development

No branches or pull requests

4 participants