SvelteKit + Google Auth: invalid request: both auth code and code verifier should be non-empty #21183
Replies: 4 comments 5 replies
-
I am currently having this issue right now and have been struggling for 2-3 days. I on the other hand am using deno fresh and I am using the SSR client. No matter what I try, I cannot get it to work. I have read docs, watched YouTube videos, checked discord server, just tried random things, used ChatGPT and more. I did come across one thing that mentioned that if running locally, which is where I am having issues, this can be an issue. But it is very informative and not proven. |
Beta Was this translation helpful? Give feedback.
-
Google led me here while encountering |
Beta Was this translation helpful? Give feedback.
-
I believe the issue is the incorrect ... = createServerClient(PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY, {
cookies: {
getAll() {
return event.cookies.getAll()
},
setAll(cookiesToSet) {
// ...
cookiesToSet.forEach(({ name, value, options }) =>
event.cookies.set(name, value, { ...options, path: '/' })
)
},
},
}) Instead of cookies: {
get: (name) => {
return event.cookies.get(name);
},
set: (name, value, options) => {
return event.cookies.set(name, value, { ...options, path: "/" });
}
} The error seems to be due to |
Beta Was this translation helpful? Give feedback.
-
I've found a solution. You have to redirect using the headers used to create the supabase client. |
Beta Was this translation helpful? Give feedback.
-
I created a new repo this morning that only has the code suggestions from https://supabase.com/docs/guides/auth/server-side/creating-a-client?framework=sveltekit and using a local DB with Google oAuth. Logging in seemed to work
I then switched back to a repo I had been working that did not work, and ended up copying across all of the src code from new repo. It continued not to work.
I then went back to this new repo, only to discover that it was now broken! By broken I mean that when the auth callback tries to call
supabase.auth.exchangeCodeForSession(code)
I get an error
AuthApiError: invalid request: both auth code and code verifier should be non-empty
I'm confident the error is not in the code, because it did work earlier today, but in some part of the broader state. I've tried removing .svelte-kit,
supabase db reset
, evensupabase init
but without success.One thing I do note is that the anon_key has not changed even despite all my resetting.
Any ideas?
Beta Was this translation helpful? Give feedback.
All reactions