I'm trying to login with Google but it throws me this error:
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, https or chrome-extension and web storage must be enabled."
This is the code:
const provider = new firebase.auth.GoogleAuthProvider();
provider.addScope('profile');
provider.addScope('email');
firebase.auth().signInWithPopup(provider)
.then((result) => {
console.log(result);
})
.catch((error) => {
console.log(error);
})
any ideas? thanks in advance!
For Android First, we need to link the native module. In RN >= 0.60 you should not need to do anything thanks to auto-linking. In RN < 0.60 run react-native link react-native-google-signin .
To get started, you must first setup a Firebase project and install the "app" module. React Native Firebase is the officially recommended collection of packages that brings React Native support for all Firebase services on both Android and iOS apps.
First I used react-native-google-signin to Sign In with Google. Follow these steps to configure it.
Make sure you correctly sign your APK (debug or release).
In app/build.gradle
exclude com.google.android.gms
from the dependencies that use it like so:
compile(project(":react-native-google-signin")){
exclude group: "com.google.android.gms" // very important
}
Then link you Google token with Firebase:
const provider = firebase.auth.GoogleAuthProvider;
const credential = provider.credential(token);
firebase.auth().signInWithCredential(credential)
.then((data) => {
console.log('SUCCESS', data);
})
.catch((error) => {
console.log('ERROR', error);
});
I'm using firebase 3.7.1
This is how my dependencies look in app/build.gradle
dependencies {
compile project(':react-native-facebook-login')
compile (project(':react-native-fcm')){
exclude group: "com.google.firebase"
}
compile project(':react-native-vector-icons')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+"
compile(project(":react-native-google-signin")){
exclude group: "com.google.android.gms" // very important
}
compile ('com.google.firebase:firebase-core:10.0.1') {
force = true;
}
compile ('com.google.firebase:firebase-messaging:10.0.1') {
force = true;
}
compile ('com.google.android.gms:play-services-auth:10.0.1') {
force = true;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With