Authenticate Using OAuth Providers with Cordova
-
I’m following this step by step but it’s not working
-
Might be an idea to drop them a message or use their forum/chat.
-
Do you have any examples using oauth?
-
I use Firebase OAuth without problems but I didn’t try with Cordova yet. I will try soon and tell you.
-
It’s working fine for me on an android virtual device (API 24) as well as on my android 6 phone.
@sostenesfreitas What is not working exactly?
-
@LaurentPayot What was your setup?
Following the instructions here:
https://firebase.google.com/docs/auth/web/cordovaUsing Quasar-0.15.14
and running:
quasar dev -m cordova -T androidIt seems to be redirecting the dev server URL in a new browser window (rather than the actual app).
Running:
const provider = new firebase.auth.GoogleAuthProvider()
self.auth.signInWithRedirect(provider)
return self.auth.getRedirectResult()opens a new browser to the google oauth page, but then redirects to the dev server URL (instead reopening the app).
I strongly suspect this has to with the way Quasar does hot reload (which fricking awesome btw!).
If I run:
quasar build -m cordova -T androidThen download the app, .auth.signInWithRedirect(provider) works as expected.
Does anyone know how to do OAuth in a cordova dev build on android?
-
@driedler I took the PWA train months ago. But I remember I had some issue with Cordova and firebase OAuth. I had to call
auth.getRedirectResult()
at thecreated
hook of my component where the authentication takes place, because the app was destroyed before sign-in was complete, so a new app was created after authentication and getRedirectResult() had to be called asap.Hope it helps…
-
Also maybe this is an issue as Cordova uses WebView if I’m right: https://developers.googleblog.com/2016/08/modernizing-oauth-interactions-in-native-apps.html
-
@driedler If someone still facing the problem, it is resolved with two lines in cordova’s config.xml file:
<preference name="OverrideUserAgent" value="Mozilla/5.0 Google" /> <allow-navigation href="*" />
Thanks to this topic https://stackoverflow.com/questions/50263489/firebase-cordova-google-login-not-working