Google Login with Firebase in React Native

I am trying to log in with Google, but this causes me this error:

code: "auth / operation-not-supported-in-this-environment" message: "This operation is not supported in the environment in which this application is running." 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);
  })

Additional Information:

  • "firebase": "^ 3.7.1"
  • "response-native": "^ 0.42.0"
  • platform: Android

any ideas? thanks in advance!

+4
source share
5 answers

react-native-google-signin Google. , .

, sign APK ( ).

app/build.gradle com.google.android.gms , :

compile(project(":react-native-google-signin")){
    exclude group: "com.google.android.gms" // very important
}

Google 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);
  });

firebase 3.7.1

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;
    }
}
+2

Firebase

"" auth, signInWithPopup(), signInWithRedirect(), linkWithPopup() linkWithRedirect() React Native ( Cordova, ). , signInWithCredential() OAuth .

+1

, , npm link, , npm link , .

npm link , compile(project(":react-native-google-signin")){, compile project ("package") , char. :

compile project(":react-native-google-signin")
{         
        exclude group: "com.google.android.gms" // very important
}

, npm link, , if.

0

, jamesjara, . . .

0

, , firebase google, , gradle

 compile(project(":react-native-google-signin")){
    exclude group: "com.google.android.gms" // very important
 }
 compile ('com.google.android.gms:play-services-auth:10.2.6'){
     force = true;
 }
 compile ("com.google.android.gms:play-services-base:+") { // the plus allows you to use the latest version
    force = true;
 }

 compile (project(path: ':react-native-fbsdk')){
            exclude group: "com.google.android.gms"
 }
 compile(project(":react-native-firebase")){
    exclude group: "com.google.android.gms"
 }

0

Source: https://habr.com/ru/post/1672282/


All Articles