N
Nuxt5d ago
mpgalaxy

nuxt-auth-utils userSession empty on server side

I'm using nuxt 4.2.1 with nuxt-auth-utils 0.5.25 using the keycloak provider (OIDC), I can set the access and refresh tokens in the onSuccess hook in server/routes/auth/keycloak.get.ts using setUserSession. I can access these data on client side with the composable useUserSession(), but when I try to access the user session on server/api/auth/refresh.ts via getUserSession(event) I get an empty session only containing a different id, no tokens, firstName, lastName or other parts of the session. How can I access the session I set in server/routes/auth/keycloak.get.ts at my endpoint server/api/auth/refresh ? @Atinux how can I do that ? I need the refresh_token to update the session regarding keycloak tokens and I don't want to do that on client side for security reasons. I couldn't find a working solution to get my refresh_token on my refresh api endpoint.
2 Replies
kapa.ai
kapa.ai5d ago
Hi @mpgalaxy. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- I'm sorry, but the knowledge sources provided do not contain specific information about the behavior of nuxt-auth-utils or the use of setUserSession and getUserSession in Nuxt 4.2.1, especially in the context of accessing the user session (including refresh_token) on the server side after setting it in a route handler. The sources discuss related topics such as handling cookies, tokens, and authentication flows in Nuxt, but do not address the exact issue of session persistence and retrieval between different server endpoints using nuxt-auth-utils. If you need to securely access the refresh_token on the server side, you may need to consult the official documentation for nuxt-auth-utils or seek guidance from the module's maintainers, as the knowledge sources here do not provide a working solution for your scenario. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai5d ago
<@975729328660832258> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?