How to authenticate in Firebase through Google using Expo (react native)?

0

I have a web application in firebase, but I'm using it in the development of an android / ios application using Expo. I want authentication to be done by Google, but it happens that because it was created as a web, it asks for ID and secret key of the client. The function looks like this:

   async signInWithGoogleAsync() {
    try {
      const result = await Expo.Google.logInAsync({
        androidClientId: 'meuandroidID',
        iosClientId: 'meuIOSID',
        scopes: ['profile', 'email'],
      });

      if (result.type === 'success') {
        const { idToken, accessToken } = result;
        const credential = firebase.auth.GoogleAuthProvider.credential(idToken, accessToken);
        firebase
        .auth()
        .signInAndRetrieveDataWithCredential(credential)
        .then(res => {
          console.log(res)
        })
        .catch(error => {
          console.log("firebase cred err:", error);
        });
        // return result.accessToken;
      } else {
        // return { cancelled: true };
      }
    } catch (e) {
      // return { error: true };
    }
   }

Then when the user authenticates, the ID sent is android or IOS, which returns the following error, saying that because it is not a web ID, it is not allowed:

[Error: {"error":{"code":400,"message":"Invalid Idp Response: the Google id_token is not allowed to be used with this application. Its audience (OAuth 2.0 client ID) is MYID, which is not authorized to be used in the project with project_number: MYPROJECTNUMBER.","errors":[{"message":"Invalid Idp Response: the Google id_token is not allowed to be used with this application. Its audience (OAuth 2.0 client ID) is MYID, which is not authorized to be used in the project with project_number: MYPROJECTNUMBER.","domain":"global","reason":"invalid"}]}}]

So how do I solve this problem and get myself logged in with Google on firebase Web using Expo react native?

    
asked by anonymous 12.11.2018 / 13:59

1 answer

0

I was able to solve it, I did the following:

IsimplyaddedtheID'stherein"Add client IDs to ..."

    
12.11.2018 / 14:59