auth-js icon indicating copy to clipboard operation
auth-js copied to clipboard

Feat/get session from url param

Open Lxstr opened this issue 3 years ago • 1 comments

What kind of change does this PR introduce?

Achieves #208.

Allows the user to optionally pass a url manually. It appears this might have been originally intended from the looks of the code.

What is the current behavior?

Supabase/gotrue method only gets url from document url.

Capacitor native app webview does not seem to be able to get a token from a normal auth callback.

What is the new behavior?

Force capacitor to get the token by using url param in the getSessionFromUrl method.

if (Capacitor.isPluginAvailable('App')) { App.addListener('appUrlOpen', async urlOpen => { const { data, error } = await supabase.auth.getSessionFromUrl( { storeSession: true, }, urlOpen.url, ) }) }

Additional context

This is equivalent to the auth0 method listed here https://auth0.com/docs/quickstart/native/ionic-react/01-login

Lxstr avatar Jan 15 '22 00:01 Lxstr

Would changing || null to || undefined fix the errors?

Lxstr avatar Jan 26 '22 23:01 Lxstr

Hi, thank you for your contribution! The library has advanced quite a bit from then. I'll close this PR for now, but do open a new one if you would like the same change to appear in v2.

hf avatar Feb 02 '23 10:02 hf