Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
581 views
in Technique[技术] by (71.8m points)

react native firebase google auth fails with developer error

i am trying to make the google sign in work for my react native firebase app. i have followed instructions to create the sha1 key and add it to firebase console but it gives this error:

[Error: DEVELOPER_ERROR]

here is the code that i am using during google sign in(it is pretty much copy paste from https://rnfirebase.io/auth/social-auth#google:

      GoogleSignin.configure({
        webClientId: '323120910892-b3ab9sq2sc1erk3120nbm6tpfukg5bv0.apps.googleusercontent.com',
      });
    import { GoogleSignin } from '@react-native-community/google-signin';
          async function onGoogleButtonPress() {
            // Get the users ID token
            const { idToken } = await GoogleSignin.signIn();
          
            // Create a Google credential with the token
            const googleCredential = auth.GoogleAuthProvider.credential(idToken);
          
            // Sign-in the user with the credential
            return auth().signInWithCredential(googleCredential);
          }
    
                  <TouchableOpacity onPress={ async () => { 
                                                  try{
                                                  await onGoogleButtonPress();
                                                  console.log('signed in using google');
                                                  }
                                                  catch(error){
                                                    console.log('error ocurred trying to sign in using google');
                                                    console.log(error);
                                                  }
                                                  
                                                }
                                  }>
                      <Ionicons  name="logo-google" size={50}  ></Ionicons>
    
                  </TouchableOpacity>

I have also added the SHA1 certificate generated to project settings. WHen i generate the signing report from gradle i get lots of SHA1 keys but they are all same but two distinct keys. i have tried both but i get the error. I think i need to add Task :app:signingReport key. so i added that to project settings, then downloaded the google service json file again and put it in react native app.

One other most likely unrelated thing is that i see this warning which is weird because all my firebase stuff is 10.1.0:

----------
ReactNativeFirebase WARNING: NPM package '@react-native-firebase/functions' depends on '@react-native-firebase/app' v10.3.0 but found v10.2.0, this might cause build issues or runtime crashes.

my package.json:

      "@react-native-async-storage/async-storage": "^1.13.2",
        "@react-native-community/google-signin": "^5.0.0",
        "@react-native-community/masked-view": "^0.1.10",
        "@react-native-firebase/app": "^10.1.0",
        "@react-native-firebase/auth": "^10.1.0",
        "@react-native-firebase/dynamic-links": "^10.1.0",
        "@react-native-firebase/firestore": "^10.1.0",
        "@react-native-firebase/functions": "^10.1.0",
        "@react-native-firebase/messaging": "^10.1.0",
        "@react-native-firebase/storage": "^10.1.0",

Any pointers will be appreciated as error message does not give much information to troubleshoot further from my side and all the other posts point to sha1 key.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...