New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API for session restore using magic links #923
Comments
Hi @henry2man there is the getSessionFromUrl method. Let me know if that solves your use case. Thanks. |
I missed this one. Probably it will work, I'll confirm ASAP. Maybe is this an opportunity to improve docs? |
@henry2man The supabase_flutter SDK will obtain the session without you having to do anything when your user clicks on the magic link and opens your Flutter app. You do not need to call neither So the sample URL that you provided uses an implicit auth flow, which is not the default auth flow for supabase_flutter. How are you generating this magic link? Are you perhaps generating it on a non-Flutter app using supabase-js, and then opening the magic link on an Flutter app or something? Whatever the situation is, you can probably fix this by setting the auth flow to implicit like this: await Supabase.initialize(
url: supabaseUrl,
anonKey: supabaseKey,
authOptions: const FlutterAuthClientOptions(
authFlowType: AuthFlowType.implicit,
),
); |
My UI is incomplete. This link is generated via (local) studio UI > Authentication > User > Send Magic Link. Thanks for these useful insights, I'll review them ASAP |
This is working like a charm.
Closing this, thanks. |
Is your feature request related to a problem? Please describe.
I'm using Flutter Web. Supabase Auth is able to perform passwordless logins. You can setup a redirect URL. I'm able to read Supabase session from URL hash query parameters (
access_token
,refresh_token
and so on), but I don't see any way to inject this parameters into current goTrue auth client in order to restore the session from these parameters.Describe the solution you'd like
A clean, maybe automatic way to read URL Parameters and/or automatic session restoring during startup and/or via explicit method. Also error handling should be done.
Sample URL: http://127.0.0.1:3000/#access_token=aaa.bbbbbbbbb.ccccc&expires_at=1715302651&expires_in=3600&refresh_token=abcabcabc&token_type=bearer&type=recovery
Describe alternatives you've considered
I've tried the
refreshSession(newRefreshToken)
during app bootstrap but sadly it looks that a proper session is needed before.Additional context
I'm using current latest version (
2.5.2
)The text was updated successfully, but these errors were encountered: