OAuth2 Token SSR
See original GitHub issueHello,
I’m currently trying to implement OAuth2 for my Nuxt 3 (v3.0.0) application. I’m able to request a valid token, login goes through and everything is set properly in the localStorage. Once I refresh the site the localStorage will be cleared {"token":"","model":null}.
I’m using the provided example https://github.com/pocketbase/js-sdk#ssr-integration
Any idea how to prevent it from clearing on a refresh?
Many thanks!
Issue Analytics
- State:
- Created 10 months ago
- Comments:19 (10 by maintainers)
Top Results From Across the Web
NextJS SSR - JWT (Access/Refresh Token) Authentication ...
Access token : short-lived token (in our example it will be around 10 seconds) that let's user access guarded by content by the...
Read more >Using OAuth 2.0 for Web Server Applications
Obtaining OAuth 2.0 access tokens ... The following steps show how your application interacts with Google's OAuth 2.0 server to obtain a user's ......
Read more >Server-Side Apps - OAuth 2.0 Simplified
We've built API access management as a service that is secure, scalable, and always on, so you can ship a more secure product,...
Read more >Server-Side Rendering - Supabase
Single-page apps with server-side rendering (SSR) is a popular way to optimize ... The first access and refresh tokens after a successful verification...
Read more >Next.js SSR Refresh Tokens - YouTube
Learn how to get refresh tokens working with Next.js and server side rendering.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@Ponkhy I’m not able to reproduce the issue. Just tested your code with a new nuxt3 project (aka.
npx nuxi init myapp) and it woks fine and the correct cookie is set both client and server side.Are you authenticating as app user or admin? If the latter then it is possible that the authRefresh call will fail, since it is for the
userscollection only.I’ve modified now the Nuxt plugin and it seems to hold the token and user infos even after refreshing. Do you @ganigeorgiev think this is a good practice?