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 add refresh token logic? #152

Closed
karkigrishmin opened this issue Sep 26, 2024 · 1 comment
Closed

How to add refresh token logic? #152

karkigrishmin opened this issue Sep 26, 2024 · 1 comment

Comments

@karkigrishmin
Copy link

karkigrishmin commented Sep 26, 2024

I'm using auto generated service.gen.ts and core.ts file. In layout.tsx file for passing token in header I have done like this:

  useEffect(() => {
    OpenAPI.interceptors.request.use((config) => {
      const { token } = getToken()

      config.headers = {
        Authorization: token ? `Bearer ${token}` : '',
      }
      return config
    })
  }, [])

Similarly, how to add refresh token logic?

cc: @7nohe

@7nohe
Copy link
Owner

7nohe commented Oct 14, 2024

I believe you can use an interceptor for responses to add refresh token logic.

https://heyapi.vercel.app/openapi-ts/clients/fetch.html#interceptors

@7nohe 7nohe closed this as completed Oct 14, 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

2 participants