使用无法在Firebase上使用的Google登录

时间:2019-04-05 09:31:15

标签: android firebase react-native google-signin

在“我的Firebase”项目中,有两个Android应用程序。我们称它们为“管理”应用程序和“用户”应用程序。我首先创建了User App,然后将SignIn与google和SigIn与Twitter一起使用。它工作正常,我能够成功登录。  之后,我在同一个firebase项目下创建了Admin App。将SHA1密钥上载到Admin应用程序下载的服务json文件。当我运行项目时,“使用电子邮件登录”工作正常。但是用Google登录失败,错误代码为16。我们该如何解决?我的代码。这与我在User App中使用的代码相同

    Glg = () => {

      GoogleSignin.hasPlayServices()
          .then(res => {
              GoogleSignin.signIn()
              .then(res => {
                console.log('res:'+res);
                const credential = firebase.auth.GoogleAuthProvider.credential(res.idToken, res.accessToken)
                console.log('res:'+credential);
                return firebase.auth().signInWithCredential(credential);

              }).then((currentUser)=>{
                //console.log('Google login with user'+ JSON.stringify(currentUser.toJSON()))
                this.props.navigation.navigate('FlyerListing')

                //--------------------------Async Test--------------------------
                  AsyncStorage.setItem("user", currentUser.uid)
                  console.log("AsyncStorage= "+ currentUser.uid)
              //--------------------------------------------------------------
              })
              .catch(err => {
                  console.log(err.code +" "+err.message);
              });
          })
          .catch(err => {
              console.log(err);
          });
    };

0 个答案:

没有答案