https://supertokens.com/ logo
Title
i

indy

12/26/2022, 6:27 AM
Hello again, I'm implementing social login and would like redirect back to the page (and the state if possible) I was already in. I think we can pass something called a state to the google auth url, how do I pass that in when using: https://supertokens.com/docs/thirdpartypasswordless/custom-ui/thirdparty-login#step-2-handling-the-auth-callback-on-your-frontend. Also is it possible to login via a popup? That would allow me to preserve my app-state.
r

rp

12/26/2022, 6:30 AM
hey @indy
give me a moment. I'll highlight the steps required to do this.
i

indy

12/26/2022, 6:53 AM
Thanks 🙂
Also is there a way to open the auth url in a new tab and it gets automatically closed? That would be the best UX, considering mobile too.
I'm just looking for options for the best UX
r

rp

12/26/2022, 8:10 AM
@sattvikc can help here.
s

sattvikc

12/26/2022, 8:13 AM
@indy you can do the following:
on the login route:
const wnd = window.open(authURL, "Login", "width=800,height=600")
const timer = setInterval(function() {
    if(wnd.closed) {
        clearInterval(timer);
        alert('login complete');
        // Check for session here
    }
}, 1000);
you would do the popup instead of doing
window.location.replace
and on the call back route simply call
window.close()
once the signInUp is done
if you wish to send success or error state, you could do that using the localStorage
i

indy

12/26/2022, 8:15 AM
That's a nice idea, thanks. Any gotchas for mobile?
s

sattvikc

12/26/2022, 8:16 AM
you want to implement browser login for a mobile app ?
i

indy

12/26/2022, 8:16 AM
Not a mobile app
Just the pop up in mobile
s

sattvikc

12/26/2022, 8:16 AM
same code should work
i

indy

12/26/2022, 8:17 AM
Yup, thanks 👍