Open AHMED-5G opened 1 year ago
To take advantage of the exchange code route method, you need to set auth > flowType option to pkce for your supabase client
However, the query parameter looks like this: exp://127.0.0.1:8081/--/resetPassword#access_token=123&expires_in=3600&refresh_token=123&token_type=bearer&type=recovery"
Multiple problems here:
Augment this for PKCE flow once you have that enabled. You also need URL polyfill to be installed.
const parsedUrl = url_with_code_as_hashtag.replace("#", "?");
const url = new URL(parsedUrl);
const access_token = url.searchParams.get("access_token");
const refresh_token = url.searchParams.get("refresh_token");
// Handle code exchanges
I'm using Supabase without PKCE with success from the above code.
However, the query parameter looks like this: exp://127.0.0.1:8081/--/resetPassword#access_token=123&expires_in=3600&refresh_token=123&token_type=bearer&type=recovery"
Multiple problems here:
- As @j4w8n mentioned you need flowtype set to pkce.
- For non PKCE flow you need to replace the # with ? to be able to extract it from the query.
Augment this for PKCE flow once you have that enabled. You also need URL polyfill to be installed.
const parsedUrl = url_with_code_as_hashtag.replace("#", "?"); const url = new URL(parsedUrl); const access_token = url.searchParams.get("access_token"); const refresh_token = url.searchParams.get("refresh_token"); // Handle code exchanges
I'm using Supabase without PKCE with success from the above code.
That is by design. The supabase client, in non-pkce mode, should be handling that scenario automatically.
That is by design. The supabase client, in non-pkce mode, should be handling that scenario automatically.
Yes I'm aware. Not Supabase problem I'm mentioning.
Bug report
Describe the bug
I am encountering difficulties with the password reset feature in while developing a React Native Expo application. The password reset is not functioning as expected, and I am experiencing inconsistent behavior with the redirect URL. Additionally, how to handle reset password after redirect what is
code
?Actual Behavior
Sometimes it's redirect to base URL
exp://127.0.0.1:8081
and some time it is redirecting to provided URLexp://127.0.0.1:8081/--/resetPassword
,Then at final approach as supabase docs:
// The code is retrieved from the query parameter - use whichever mechanism is recommended // for your app/framework. This is just an example. const code = url.searchParams.get('code')
// call the Supabase API to exchange the code for a session await supabase.auth.exchangeCodeForSession(code)
LoginScreen.ts
Screenshots
System information