Google OAuth not working locally #20353
Replies: 14 comments 14 replies
-
cc @silentworks who knows this stuff inside out. But I think you redirect_uri should be blank there. That should be in your Google app settings. Also, are you sure your env vars are working? Have you tried pasting them into here directly? (you don't want to commit that file then, but useful for testing) |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Getting a similar issue here. This is a non starter for developing locally with supabase /: |
Beta Was this translation helpful? Give feedback.
-
I use Flutter and have the issue with google sign in as well. I have the following issue. flutter: ClientException with SocketException: Connection refused (OS Error: Connection refused, errno = 61), address = 127.0.0.1, port = 55038, uri=http://127.0.0.1:54321/auth/v1/token?grant_type=id_token [auth.external.google]
enabled = true
client_id = "env(GOOGLE_CLIENT_ID)"
secret = "env(GOOGLE_CLIENT_SECRET)"
redirect_uri = "http://localhost:54321/auth/v1/callback" |
Beta Was this translation helpful? Give feedback.
-
Same issue as the people above. Erratic behaviour on oauth with google locally but works perfectly on prod. |
Beta Was this translation helpful? Give feedback.
-
no matter what i do, i keep getting "AuthApiError: invalid flow state, no valid flow state found" locally. |
Beta Was this translation helpful? Give feedback.
-
Facing the same error. Has anyone solved this already? |
Beta Was this translation helpful? Give feedback.
-
same issue |
Beta Was this translation helpful? Give feedback.
-
Seems to be working in prod correctly but I managed to solve it for localhost also. You just need to add redirectTo option to your request. Just redirect to your own back-end which handles to code switch correctly. async function Login() {
const { data, error } = await supabase.auth.signInWithOAuth({
provider: 'google',
options: {
redirectTo: "http://localhost:3000/auth/callback",
queryParams: {
access_type: 'offline',
prompt: 'consent',
},
},
})
} |
Beta Was this translation helpful? Give feedback.
-
I finally figured it out after months of struggling! The bug comes from how redirect URLs are set up with wildcards in the Supabase Authentication / URL Configuration settings. My project is set up similarly to OP in that after signing in, the provided redirectTo value is HOWEVER - if you look at the docs, the single * is only used to match non-separator characters, which are '.' and '/'. So the redirectURL To fix: change the redirect URLs to |
Beta Was this translation helpful? Give feedback.
-
I had the problem that my app was running on It finally worked out when I set |
Beta Was this translation helpful? Give feedback.
-
Facing this error still Steps followed - Same issue even with Azure Although login happens, cannot get the session/user |
Beta Was this translation helpful? Give feedback.
-
I fixed with api.tls settings. After this settings now I have a certification problem (because config.toml [api.tls]
enabled = true After restart supabase, it returns the new url with https. So changed supabase url in my project setting. After this, nextjs whined about invalid https so I add this variable to environment. (I'm pretty sure other framework has a similar problem) NODE_TLS_REJECT_UNAUTHORIZED=0 If you run playwright test, add I can't sure this solution will fix everyone's problem, but hope to help some. |
Beta Was this translation helpful? Give feedback.
-
Same issue here. It seems like local Google auth is only available for PKCE flow? We should not be getting |
Beta Was this translation helpful? Give feedback.
-
Bug report
Describe the bug
I'm testing Google OAuth with my NextJS app router project with the latest libraries (supabase-js and supabase/ssr). Everything works perfectly when I setup everything correctly according to the guide on a remote Supabase environment (I've done this before several times).
However, this is the first time I'm trying to set this up locally for convenience, but I'm having issues. After adding this to my
config.toml
:I start getting haphazard behaviour. The redirect doesn't work, it does not take me to the logged in page of my app. (Note that this works perfectly in staging/prod). If it helps to know, when I sign in with google on localhost:3000, it takes me to
127.0.0.1:3000?code=xyz
(where code is the code I get from signing in) but doesn't go further than that.Also to note, I'm using OAuth with PKCE flow. So there's a route handler that intercepts the flow, gets a session in exchange for code (and also does some DB manipulation) and then redirects back to home.
To Reproduce
Follow the guide on setting up Google Oauth with Supabase and NextJS, and also testing Supabase locally.
Expected behavior
Redirects should happen properly, without it taking me back to home while being in a signed out state (That's currently happening right now).
System information
"@supabase/ssr": "^0.0.10",
"@supabase/supabase-js": "^2.38.5",
Beta Was this translation helpful? Give feedback.
All reactions