Google as an Auth provider doesn't work on iOS saved to homescreen
[REQUIRED] Describe your environment
- Operating System version: iOS 10
- Firebase SDK version: 4.1.3
- Firebase Product: auth
[REQUIRED] Describe the problem
Steps to reproduce:
- Save the app on the homescreen on iOS
- make a redirect or popup login with google Auth provider
- if redirect:
- webview is not a "valid user agent"
- if popup:
- gets stuck in Safari about:blank, doesn't open the app again to pass on the token
Relevant Code:
import firebase from "firebase";
const config = {
//...
};
firebase.initializeApp(config);
const googleAuthProvider = new firebaseAuth.GoogleAuthProvider();
firebase.auth().signInWithRedirect(googleAuthProvider);
// or
firebase.auth().signInWithRedirect(googleAuthProvider);
related issue: https://github.com/firebase/quickstart-js/issues/94
This is a known issue and not really Firebase related (in the case of redirect) which is Google sign-in related. Webviews are insecure and Google sign-in no longer works in that environment anymore. Google sign-in recommends using SFSafariViewController for this but homescreen apps cannot run in a SFSafariViewController, instead they always run in a webview environment. As for popups, they won't work for a different reason since Firebase OAuth popup relies on web storage to pass the result back to the app. However homescreen apps do not share the same web storage as the system browser (which is how the popup is opened).
I totally understand that, but saving to home screen isn’t something I have control over as an author. Does this really come down to “it’s impossible”?
Unfortunately, it is currently impossible if you wish to use Google Sign in. If you are using other providers, you can use the recommended signInWithRedirect for that mode (it should work).
This is a pretty big, deal breaker, any hope/news on this ?
Sorry, it is out of our control. You need to reach out to the Google OAuth folks about this. I don't think there is currently anyway to get Google sign-in to work in a home screen iOS app.
Android is also effected by this issue, this is definitely a deal breaker for pwa
There are still no solution for this problem?
Have just run into this issue myself, some of our users are trying to launch from iOS bookmarks and are unable to sign in. I appreciate this is not a firebase issue per say but wanted to add my voice here to draw attention that there are more affected users.
I am using firebase web authentication, is there no way to allow login from iOS in this instance?
Thanks
This makes me sad.
Facebook login and other non-Google providers should work in redirect mode only. As I mentioned earlier, it is impossible to get Google sign-in in that iOS homescreen mode. From the Google sign-in perspective, it is coming from an embedded webview which are now blocked.
Does anyone know where we can follow the progress on this PWA deal breaker ?
We would welcome a solution to this problem as well. Unfortunately this is a "deal breaker" for us as well.... I wanted to share on this thread as we are running into this same issue and did not want to be silent about it.
Looking forward to a resolution soon!
How do we upvote a solution?
Does anyone know where we can follow information on how this problem is being treated by either Google OAuth, Apple or Firebase?
Is there a way for firebase to detect if the app is launched from the home screen so we can display an explanation for our users?
The iOS embedded webview has a distinct useragent. You can test for that and display a message to the user. Embedded webviews for iOS 9 and above are blocked from accessing the Google OAuth page for security reasons: https://developers.googleblog.com/2016/08/modernizing-oauth-interactions-in-native-apps.html
Why not just:
var fbAppId = 'XXXXXXXXXXXXXX';
var fburl = "https://www.facebook.com/dialog/oauth?";
fburl += "client_id="+fbAppId;
fburl += "&redirect_uri="+window.location.href;
window.location.href = fburl;
When popup is not possible, like in Safari?
@RileyDavidson-Evans Look: https://bugs.chromium.org/p/chromium/issues/detail?id=771418 seems to be fixed in Chrome dev 64.0.3254.2
Actually, I tried https://fir-ui-demo-84a6c.firebaseapp.com/ posted in the thread above with just the latest stable Chrome and couldn't reproduce the endless loop. Maybe someone fixed something behind the scene already?
For me it looks like redirect auth works on https://friendly-pix.com/ on iOS homescreen apps with Google sign-in. But perhaps, since this is an old app, I was grandfathered into an exception.
Popup auth works on Android Homescreen apps.
This is how I implemented an exception just for iOS homescreen apps:
var signInFlow = 'popup';
// For iOS full screen apps we use the redirect auth mode.
if (('standalone' in window.navigator)
&& window.navigator.standalone){
signInFlow = 'redirect';
}
// FirebaseUI config.
var uiConfig = {
'signInFlow': signInFlow,
'signInOptions': [
firebase.auth.GoogleAuthProvider.PROVIDER_ID,
firebase.auth.FacebookAuthProvider.PROVIDER_ID
]
};
var firebaseUi = new firebaseui.auth.AuthUI(firebase.auth());
When I tested today it worked without problems. Was this problem fixed on Apple's side (related to webviews) or Google OAuth side or Firebase side?