supabase / supabase-flutter

Flutter integration for Supabase. This package makes it simple for developers to build secure and scalable products.
https://supabase.com/
MIT License
656 stars 154 forks source link

Saving sessions for logging in via facebook #916

Closed jlukas99 closed 1 month ago

jlukas99 commented 1 month ago

Hi, I have a problem because after logging in via facebook I am only logged in until the app is live, when you crash and reopen the app, the session is not saved and a re-login is required, for native login via google and apple, everything works fine, did I miss something in the implementation or is it a bug? Thank you in advance for any attempt to help

dshukertjr commented 1 month ago

Session refresh works the exact same way with all authentication methods, so it is weird that it's happening for facebook logins only. I suspect that the cause might be something to do with deep linking.

I am only logged in until the app is live

How are you verifying that the sign-in was successful?

when you crash and reopen the app

Could you tell me what exactly you are doing in this step?

jlukas99 commented 1 month ago

How are you verifying that the sign-in was successful?

Listens for the authorization state, if the state appears sign in, performs subsequent operations

Could you tell me what exactly you are doing in this step?

I close the app so that it is not running in the background and fire it up again, when logging in by email and natively by apple or google, it reads the saved session from memory and here there will be a problem with deep link, because I don't know why it doesn't seem to save it, after logging in, so that when I restart the app it doesn't log in automatically, from what I can see with twitter there is the same problem, generally it doesn't work when authentication is done with webview

jlukas99 commented 1 month ago

My deep link look like that after sign in via facebook

Zrzut ekranu 2024-05-7 o 10 33 34

dshukertjr commented 1 month ago

@jlukas99 Could you try if the same thing happens with magic link login? Also, what version of supabase_flutter are you using?

jlukas99 commented 1 month ago

@dshukertjr Sure will try with the magic link and let you know

supabase: 2.1.2 supabase_flutter: 2.5.2 flutter: 3.19.6

jlukas99 commented 1 month ago

Sorry, but it turned out to be a problem on my side, I have the user downloading and setting the login status while listening and checking if it is SignedIn, and I should add an initialSession to it, also the problem solved itself, what programmers like the most 😂