auth.login() Error "location.protocol" must be http or https
auth.login() has an error when attempting to authenticate with Google or Facebook on an iOS or Android device using Cordova.
Here is a code sample:
this.af.auth.login({
provider: AuthProviders.Google,
method: AuthMethods.Popup
}).then((value) => {
//success
}).catch((error) => {
console.log(error);
});
Running version 2.0.0-beta.3-0930330 of angularfire2.
When run in a Cordova app the error callback will be called with this message:

Same that #270
Yikes, seems like signInWithPopup() has the same protocol check as getRedirectResult(). https://firebase.google.com/docs/reference/js/firebase.auth.Auth#signInWithPopup
I'm a little out of my depth here on what the right way to solve this is...
@davideast can you ask around about this?
signInWithRedirect seems to have the same issue than signInWithPopup()
Same issue with credential method and cordova-plugin-facebook4 (http://stackoverflow.com/questions/37768313/using-firebase-auth-with-facebook)
if (this.platform.is('ios') || this.platform.is('android')) {
Facebook.login(['public_profile']).then(function (result) {
console.log("Facebook success: " + JSON.stringify(result));
authGlob.login(result.authResponse.accessToken, { provider: AuthProviders.Facebook })
.then((success) => {
console.log("Firebase success: " + JSON.stringify(success));
})
.catch((error) => {
console.log("Firebase failure: " + JSON.stringify(error));
});
})
Facebook success: {"status":"connected","authResponse":{"accessToken":"...","expiresIn":"5110794","session_key":true,"sig":"...","userID":"..."}}
app.bundle.js:500 Firebase failure: {"code":"auth/operation-not-supported-in-this-environment","message":"This operation is not supported in the environment this application is running on. "location.protocol" must be http or https."}
After some correction I find a work around. I propose some add to the documentation #287
Any way to make it work? Thank you.
looks like some PR is needed for either firebase 3 or angularfire2. also seems that the difficulty now is to specify the area of responsibility which is now a pingpong between firebase, angularfire2 and also the ionic. Actually I'm little confused which is (and if there is any) github repo for JS firebase 3 as firebase package on npmjs.com points to firebase.google.com
So as a first step it would be great to have clear if it is acceptable that i.e. file:// protocol is supposed to be handled, and then if the patch is required on the firebase or angularfire2.
Any suggestions or even better PRs will be very valuable.
does it make sense to add some Help Wanted! or other label to raise the importance/severity? looks like this is actually a blocker for ionic/phonegap apps.
Yes, you're right.
Any news about this?
I haven't seen any activity on this in awhile. I don't know if cordova support is a priority for the angularfire team at this point.
I guess that it's not about the cordova but about a use case of app loaded from file - there is rather no reason why it should not be supported. And also this was working with firebase 2 (togheter with i.e. https://github.com/ciekawy/angular2-firebase) so this is kind of regression for people moving to new recommended firebase 3 SDK
Since upgrading to firebase 3 in my ionic app I have had many major breaking issues I'm about a month behind :( are there any temporary fixes?
I don't know who is developing AngularFire2 but the problem is on the Firebase side.
I contact the Firebase team and this the answer: Are you using popup / redirect sign in methods in Firebase 3.x.x? If so, these methods are currently not supported in native Ionic/Cordova apps. Sorry about that. As a workaround, I recommend to use a library for OAuth such as ngCordova(in Cordova and Ionic apps) and then use auth().signInWithCredential(...) to sign your users in.
@cnothegger Could you elaborate on the fix, I don't understand how using sign in with credentials can login oauth firebase users. Is this something that needs to be pushed to ionic to fix? thanks
I think this thread is mixing issues, you can login to firebase using a plugin to get the oauth credentials and pass them through. Yes it is as neatly integrated in to angular fire, but there is a work around
Solved using Firebase only.
Check this: Advanced: Handle the sign-in flow manually https://firebase.google.com/docs/auth/web/facebook-login
This seems to be fixed in a cordova environment (specifically Ionic 2) with angularFire2@next but i can't seem to get any auth information. If you subscribe to AngularFire.auth() it never actually fires when the user logs in. Works fine in Chrome. Im guessing this issue is related to this line https://github.com/angular/angularfire2/blob/master/src/auth/auth.ts#L45. Unfortunately that looks like the line that fixed auth.login() not working.
@Lindstrom1989 @jgw96 This solution using ionic-native facebook plugin to get the accessToken, creates the credential and then successfully logs in using angularFire2 https://github.com/aaronksaunders/basicaf2
@aaronksaunders Thank you for the complete working project!
I kept getting typescript build errors til I saw your declare var firebase: any trick.