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

Add features for refresh token #356

Open
guilherme-codes opened this issue Feb 17, 2025 · 2 comments
Open

Add features for refresh token #356

guilherme-codes opened this issue Feb 17, 2025 · 2 comments

Comments

@guilherme-codes
Copy link
Contributor

guilherme-codes commented Feb 17, 2025

I'm having trouble handling refresh tokens because setUserSession doesn't update the session. So, I'm considering the possibility of adding options to setUserSession or returning an updateSession function along with the useUserSession composable.

Other ideas could be add options to refresh token in the route files... and maybe add the refresh token method to the providers definitions too.
I'd like to know people here think about this

P.S: I read the others topics talking about this issue and I think we don't have a good solution yet

// expose update session
const { updateSession } = useUserSession()

updateSession( {
  token: 'token',
   refresh_toke: 'token'
})
// allow session mutation by setUserSession
setUserSession(event, {
  token: 'token',
   refresh_toke: 'token'
}, { updateSession: true })
// add refreshtoken callback
export default defineOAuthAuth0EventHandler({
    async onSuccess(event, data) {},
    async onRefreshToken() {}
})
@Crease29
Copy link

Crease29 commented Feb 23, 2025

Hey, I'm having a similar issue when refreshing the auth0 access token. I'm calling setUserSession with the new tokens. They get sent to the client correctly, but it seems like on the next refresh request the server still has the old tokens in the UserSession. Have you found a fix/workaround for this already?

This is my workaround for now: #357 (comment)

@guilherme-codes
Copy link
Contributor Author

@Crease29 I did my own implementation for now. It is based on nuxt-auth-utils and shows how I think we should have control of sessions sending requests directly to a Nitro server using composables.

https://github.com/guilherme-codes/nuxt-auth0

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