supabase / supabase-js

An isomorphic Javascript client for Supabase. Query your Supabase database, subscribe to realtime events, upload and download files, browse typescript examples, invoke postgres functions via rpc, invoke supabase edge functions, query pgvector.
https://supabase.com
MIT License
2.86k stars 220 forks source link

`supabase.createClient` not reading in access token from URL and initialising session object when using Google or Github sign in. #966

Closed pgibler closed 3 months ago

pgibler commented 3 months ago

Describe the bug

supabase.createClient is not reading in the access token from URL and initializing the session object when using Google or Github logins.

Logging in with username / password works.

To Reproduce

Repository example: https://github.com/pgibler/supabase-js-oauth-issue

  1. Click "Sign in with Google"
  2. Sign in with account, redirect to page
  3. Access token remains in URL. Session is still null.

Expected behavior

After logging in using the Google provider and being redirected back to the application, the session should not be null. The access token should be read in and the session should be available.

System information

Additional context

It works in production. The access token is read from the URL and the session is initialized. It fails in both my primary development application the example repository application.

I can't tell what could be causing this. Been spending a lot of time debugging this and I'm completely at a loss.

To add more context, const session = supabase.auth.getSession() silently fails when invoked in this example.

My guess was project configuration for the longest time. But I've been reading documentation and watching videos on how to setup the auth all day and everything looks right. I can log in with Google, but after the redirect, the access token stays in the URL and the session remains null. And it works in production. I am new to supabase could use some support from someone who knows supabase better than me.

pgibler commented 3 months ago

I made a new project and it works now. Tried this with two different new projects and the same settings at my original one, and both new ones worked.

Then went back to using the original project, and the same issue occurred.

I'm all set with this issue now. I can report the specific project that wasn't working if it would be useful. Otherwise I'll delete it.