Reputation: 399
I have login page with Facebook (I am working with Firebase Auth) and when I run my app on my device and click on the login button I get the error message:
This operation is not supported in the environment this application is running on. "location.protocol" must be http or https and web storage must be enabled.
and the error code is:
auth/operation-not-supported-in-this-environment
If I run this app in my Google Chrome, its working great. Where is the problem?
Thanks.
Login Code:
var provider = new firebase.auth.FacebookAuthProvider();
firebase.auth().signInWithPopup(provider).then(function(result) {
// This gives you a Facebook Access Token. You can use it to access the Facebook API.
var token = result.credential.accessToken;
// The signed-in user info.
var user = result.user;
console.log(user);
// ...
}).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
console.log(errorMessage);
console.log(errorCode);
var email = error.email;
// The firebase.auth.AuthCredential type that was used.
var credential = error.credential;
// ...
});
Upvotes: 0
Views: 950
Reputation: 30788
As Channing said, currently this is not supported in Cordova. You need to use a Cordova plugin for facebook sign in. On success, you will get an OAuth 2 access token or id token. You then initialize an auth credential and call signInWithCredential using the web sdk:
firebase.auth().signInWithCredential(firebase.auth.FacebookAuthProvider.credential(fbAccessToken)).then(function(user) {
// The facebook user is now signed in.
}).catch(function(error) {
// Some error happened!
});
To get the fb access token, you can use for example the following plugin i found: https://github.com/Wizcorp/phonegap-facebook-plugin
Upvotes: 1