Oauth redirect URL method in a Cordova web app

283 views
Skip to first unread message

Nir Sharony

unread,
Dec 19, 2017, 7:51:05 PM12/19/17
to Firebase Google Group
Hello,

I am develop a Web app using PhoneGap Build and would like to implement Oauth authentication.
The documentation reference is here: https://firebase.google.com/docs/auth/web/cordova

My app is a single-page application that gets loaded entirely when the app launches.
From that point on, all the interaction is done via JavaScript and various divs in the page get displayed or hidden to reveal or hide content.

My question is how should the redirect URL be set in such scenario?
When my app loads, the value I get when logging window.location.hostname,is an empty string.
I am not sure what host I should set in the redirect URL for this to even work.
It's not even localhost which is one of the default authorized domains.

I wonder if I should be using this plugin to control the return to my app:
On the Firebase documentation page, it says to enable Dynamic Links.
However, when I go to that section in the console, it seems that this is only available for native iOS and Android apps...

Am I handling this all wrong?

Thanks,
Nir

Bassam

unread,
Dec 20, 2017, 4:29:23 PM12/20/17
to Firebase Google Group
Hey Nir,
It is not clear what you are trying to do. `signInWithRedirect` should handle the redirect from your app to OAuth authorization endpoint and back to your app without any manual redirect on your end. You can intercept the result via `getRedirectResult`.

Best regards,
Bassam

Hamilton Tenório da Silva

unread,
Dec 20, 2017, 5:24:00 PM12/20/17
to Firebase Google Group
Hi, You need to control it in callback and change the page.

You can see this in my app "Pais e Filhos: Pai" or "Pais e Filhos: Filho" (in portuguese). In any of them, you can auth using Google, Facebook or Twitter. 

In my app, I check if the user is connected. If not, I call the login page. If yes, I call the next page.

Try it.

Hamilton
Reply all
Reply to author
Forward
0 new messages