SupabaseS
Supabase4y ago
Noah

NextJS getServerSideProps capture Google login callback

I use Next.js with @supabase#0835/auth-helpers-nextjs with Google Auth. This is the flow that's happening after a user logs in with Google:

  • I get a callback request from Google that contains the access token
  • gSSP in Next sees that we’re not yet authenticated (because I have a check for protected pages)
  • This check redirects to login page
  • Client side Supabase sees access token and authenticates us
  • Manual reload required to get away from login page to dashboard
The problem I see is that the Supabase client side JS deals with the callback coming from Google. That way the getUser in my gSSP still thinks I'm unauthenticated. What's the most elegant way to immediately be let through to my protected page on the Google callback?

For example, is there a onAuthenticated callback in the Supabase JS client I can use to redirect on client after Supabase has parsed the token?
Was this page helpful?