Google OAuth with Next.JS runs into error in SupabaseAuthClient._exchangeCodeForSession
So, its my first time working with Supabase and I am trying to setup Google OAuth authentication following the docs at:
https://supabase.com/docs/guides/auth/server-side/oauth-with-pkce-flow-for-ssr
The initial steps are all pretty clear, I've setup Google as an OAuth Provider for GoTrue and then trigger the OAuth with this
And this does correctly trigger the Login Workflow, it does create the user in supabase, it does redirect to the Auth Route Handler for exchanging the code, it does provide the code to that Route Handler and it does set the
It seems that for some reason the GoTrueClient is not able to load the code verifier. Its this bit in the GoTrueClient that is throwing the error:
So for some reason it fails to correctly read the code verifier from the Cookies. Am I doing something wrong? Or is this a bug?
https://supabase.com/docs/guides/auth/server-side/oauth-with-pkce-flow-for-ssr
The initial steps are all pretty clear, I've setup Google as an OAuth Provider for GoTrue and then trigger the OAuth with this
handleLogin function:And this does correctly trigger the Login Workflow, it does create the user in supabase, it does redirect to the Auth Route Handler for exchanging the code, it does provide the code to that Route Handler and it does set the
sb-localhost-auth-token-code-verifier Cookie. However supabase.auth.exchangeCodeForSession(code); then runs into an error:It seems that for some reason the GoTrueClient is not able to load the code verifier. Its this bit in the GoTrueClient that is throwing the error:
So for some reason it fails to correctly read the code verifier from the Cookies. Am I doing something wrong? Or is this a bug?
Learn how to configure OAuth authentication in your server-side rendering (SSR) application to work with the PKCE flow.