Need to reload to use Supabase auth
Whenever I sign in on Supabase (I've tested Firefox and Brave), it brings me back to the home page as it should but I'm not authenticated. Although, after I reload the page, I am authenticated and everything works as intended.
How would I go about solving this bug?
22 Replies
and I have even tried reloading after I run my function. No luck at all.
Please ping me if you end up responding, solving this bug is pretty critical to my application :ferrisSob:
@harsh singh Normally you need to monitor .onAuthStateChange() for a SIGNED_ID event and not use the session until after that.
V2 I believe getSession() will actually wait for things to resolve.
Wait, will I need to use the authentication helpers for this?
Because that's not an option for me since my backend is in Rust
and pretty much completely separate from everything
How are you sending the jwt to your backend right now?
I'm using social auth
I'm using the Supabase library to login from the frontend
My backend doesn't have much to do with the authentication at all
I don't know what your question is then about auth helpers.
Oh no, I thought the getSession was only for auth helpers?
Auth-helpers is only for doing server side stuff. The supabase-js will handle all auth on it's own.
getSession replaces .session() in supabase-js v2.
Awesome!
is this out yet or no?
Yes. I've ported over and all seems fine... It is still rc
Oh, I see
You can use it certainly on a new app.
@supabase/supabase-js@v2.0.0-rc.4 is out now.
You really should start using v2 for anything new. I think 3 months is maintenance support for v1.
I'll try that out, thanks for letting me know!
and I'll tell you how it goes too
Quick question @garyaustin, can getUser run on the server?
:blob_think:
With a jwt parameter yes.
I see.
What if I'm using GitHub OAuth?
The user jwt access token does not matter how you signed in.
Oh.
Where could I get that from?
Also, I'm having some issues, for instance I want to get my thing working without using await:

It is in the session object
Oh, I see.
You probably need to ask new question if more. I’m out.
Oh alright, thanks for your help.
This issue works with the upgrade. Thanks for that tip.
I'll close this in favour of #Unable to use getUser without async