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

How to do a refetch process with react-oidc #1324

Open
MichalJana opened this issue Mar 15, 2024 · 4 comments
Open

How to do a refetch process with react-oidc #1324

MichalJana opened this issue Mar 15, 2024 · 4 comments

Comments

@MichalJana
Copy link

Hi, I have a question,

When using @axa-fr/react-oidc with RTK Query or Axios, it's not possible to call refreshToken and use refetch process when a 401 error is returned. The issue is that refreshToken cannot be called outside of a tsx component.

Here is an example of how refetch is done in RTK Query, and it's similar in Axios or any other similar libraries as well:
Automatic re-authorization by extending fetchBaseQuery

How do you address this situation?

@meesvandongen
Copy link
Contributor

You could use

import { OidcClient } from '@axa-fr/oidc-client';

await getOidc().renewTokensAsync();

@guillaume-chervet
Copy link
Contributor

The librairy refresh tokens automaticaly in background.
The clean way to use it is here: https://github.com/AxaFrance/oidc-client/blob/main/packages/oidc-client/src/fetch.ts

like @meesvandongen said upper, you can use directly @axa-fr/oidc-client.

@MichalJana
Copy link
Author

Hi, using @axa-fr/oidc-client would mean I'd have to unnecessarily create a wrapper that is already provided by @axa-fr/react-oidc. Is it possible to use both packages in the project simultaneously?

@guillaume-chervet
Copy link
Contributor

Yes it is possible @MichalJana

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

3 participants