ionic-team / cordova-plugin-wkwebview-engine

Mirror of Apache Cordova wkwebview engine plugin
Apache License 2.0
289 stars 66 forks source link

Firebase social login not working! [UserAgent not allowed error] #172

Open majid701 opened 7 years ago

majid701 commented 7 years ago

wkwebview works great! Huge performance improvement on iOS compared to the UIWebView.

I'm using firebase inside my app and social login to log the users in with their gmail account.

I followed this guide https://firebase.google.com/docs/auth/web/cordova to implement it and it worked fine with the UIWebView. It uses the sign in with redirect method that opens a webview inside our ionic app and handles the OAuth flow.

But with the wkwebview it's not working anymore firebase is giving disallowed_useragent error.

Is there a way to fix this? Will spoofing the user agent before making the request make it work?

img_1372

BrainBacon commented 7 years ago

This doesn't look like a problem with the wkwebview-plugin. Google is specifically blocking your method. I wouldn't recommend spoofing your User-Agent even if you can for security and compatibility reasons. What you should be doing is redirecting to the native browser (not using an embedded webview) when the user is authenticating and use a Custom URL Scheme to redirect back into the app once the user is authenticated. It looks like that is what the Firebase documentation is suggesting, so you should follow their instructions.

gregor-srdic commented 7 years ago

For social login with google, regardless of using Firebase or any other method, and regardless of using webview or wkwebview, you need to use the safari view controller or chrome custom tabs plugins. Follow the plugin instructions in this tutorial: https://firebase.google.com/docs/auth/web/cordova

gregor-srdic commented 7 years ago

Unfortunately I also encountered problems with social login, even after following the above mentioned tutorial. The social login page gets opened in the system browser, but is then redirected to localhost instead of the app deep-link (to be opened in the app itself). Has anyone got the Firebase social login working with this? Thanks!