-
-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Supabase Auth bug exchangeCodeForSession returns "both auth code and code verifier should be non-empty" #1026
Comments
Is this why redirectTo not working? It only works on base /. Also trğggers ...supabase.co/auth/v1/user twice. |
Have you logged The exchangeCodeForSession needs access to both of these - by passing in the code and having access to cookies. |
redirectTo works for me though... @j4w8n yes debugged on client and server, both are getting the |
@luisfelipeluis49 I see you're using the ssr library, which uses cookies for storage. With the pkce flows, supabase will create a code verifier and store it as |
I should correct myself: the ssr library typically shows using cookies for storage, but you may be passing it a different type of storage (you don't show that code). UPDATE: yes you show cookie storage, I'm sorry. |
I dont use ssr, it is pwa; redirectTo site/auth/dashboard doesnt create a session, without redirectTo it creates session but only to base / |
@qxygene1 if you're not using the ssr library, you should probably open your own issue so we don't get messages confused. |
So, no idea what's happening right? |
@luisfelipeluis49 is the code verifier cookie there? |
@j4w8n I'm not sure, I know that I'm passing as supposed to be, but I don't know where I can check this
When I tried to see what was on client I added this code to see in the debugger
And inside of client there was it: |
I'm not sure how to check if you're using mobile. If possible, might try on a desktop browser. |
@j4w8n I'm testing on desktop chromium based browser (Microsoft Edge), using http://localhost:5173 |
Then you should be able to check for the cookie in dev tools - after you try to login. |
It gets set when you call signInWithOAuth and gets accessed and then deleted when you call exchangeCodeForSession. I don't believe you will ever see it in a header unless you're calling exchangeCodeForSession on the server side. |
@j4w8n it supposed to set when calling signInWithOAuth, I can see it when debugging on setAll, but I'm not sure if it's there when calling exchangeCodeForSession, it is indeed on server side, do you know how can I check it? |
Should be in the request headers of your auth callback then. If there is middleware, might check there too. |
And just to show, when on cookiesToSet this code is generated, it just doesn't seem to be stored:
|
I'm not sure why it wouldn't be stored, but this is def your issue. |
@j4w8n can you at least say to me what should be inside of storage here in:
I made a workaround to store and pass the key as a header of my request, but it seems to "break" here for me, cause storage it's like this for me: |
The storage is whatever you want it to be. Like I said, with the ssr library people typically use a cookies implementation, but you can use whatever works best for what you're trying to do. I'm not familiar with Capacitor and what it has access to. |
Capacitor doesn't play a role in here, I only mentioned to avoid solutions like "use SvelteKit", because that isn't an option for my use case. It's a simple CSR website using Svelte and Fastify. In the end, I found a way to access the storage and pass the auth-token-code-verifier, it's requests in Now, my only remaining question, what does it expect it to be? I put the e.g. |
That format looks correct, but it's definitely unique per call to |
I think your
What does your Supabase client-creation code look like on the client side? |
Unless I'm triggering this twice, then should be the same.
I'm not using any supabase on client only on server side |
Bug report
Describe the bug
Architecture:
Client: Svelte + Vite + Capacitor
Due to use of vanilla Svelte, to handle navigation our choice was "svelte-routing", for building the app on both web and mobile (iOS and Android) we use Capacitor.
Server: Fastify + Supabase
Our server framework of choice was Fastify, as long w/ Supabase, and thus we need to use the Supabase Auth solutions, what prevent us from using tools like Capacitor Generic OAuth2.
Problem
Following the Supabase guide to implement Google OAuth2, when storing the user session, got an AuthApiError: "invalid request: both auth code and code verifier should be non-empty"
Packages:
Code
Front:
Google sign-in button:
Auth Callback:
Server:
Supabase client configuration:
Auth controller:
Updated all packages, enabled flow type pkce, implemented getAll and setAll instead of get, set and remove on cookies options. But all for nothing, got the same error and couldn't get the solution to this error
System information
The text was updated successfully, but these errors were encountered: