Closed NicolasDeGouveia closed 8 months ago
Are you using hosted supabase or a local stand-alone?
I'm using a local stand-alone
@NicolasDeGouveia can you please include the code you used to initialise the supabase client?
I initialize the supabase client with : const supabase = createClientComponentClient();
@NicolasDeGouveia are you calling the handleSignInClick
function from the client-side or server-side? the supabase client you created with createClientComponentClient()
returns a supabase client that uses PKCE for auth. This means that after the oauth flow is completed with google, supabase auth returns a code in the query param which will be exchange for a pair of access and refresh tokens.
If you open up your browser network inspector when being redirected to http://localhost:3000?code....
, you should be able to see requests made to /token?grant_type=pkce
and check if they are failing. This is the endpoint that handles the code exchange i mentioned earlier. If no requests are made to that endpoint, can you reach out to us via support (https://app.supabase.com/support/new) and we can investigate further.
@kangmingtay I'm using it in the client-side. I don't know why but now it's seems to work, but now when i'm logged with google i'm well redirected to my homepage but i must press F5 to be able to see the user connected, even if i have a router.refresh()
in my function :
const handleSignGoogle = async () => {
await supabase.auth.signInWithOAuth({
provider: 'google',
options: {
queryParams: {
access_type: 'offline',
prompt: 'consent',
},
},
});
router.refresh();
};
Any ideas of why ?
@NicolasDeGouveia not too sure what router.refresh()
here does but calling it right after signInWithOAuth()
won't help because signInWithOAuth()
only redirects you to the oauth provider (google) to kickstart the oauth flow. After authenticating with google, you are actually redirected to an endpoint on Supabase Auth first before redirecting again back to the client.
You can try moving router.refresh()
to your homepage and see if that helps. Since this issue is resolved, i'm gonna mark it as closed for now.
Bug report
Describe the bug
After setting up my login with credentials (that work perfectly good) i tried to setup the google provider. I followed the documentation but when i click to login, i'm redirected to the google login page, i choose the user that i want, and then i'm redirect to my app but not connected. I see the new user in the database with the status "never" in the row "Last Sign In". When i try again that row update with the current date but in my app i'm not logged in.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
Expected behavior
I want to be connected after the google redirection.
Screenshots
this is my login function : https://gyazo.com/bd500927a2a5331ec5a54ff34ab87204
this the URL i got when i'm redirect to my website : https://gyazo.com/73724c00ad7a62ce9be91e7b90a81385
System information
Additional context
Add any other context about the problem here.