1

First Image:

enter image description here

Second Image: enter image description here

Here is my code to create the GoogleSignInOptions object. In the requestIdToken argument, I put the web client id from the firebase console of my app(Check first image). But i read an article that web client id should be created on the page "https://console.developers.google.com/apis/credentials?project=feisty-truth-232713&folder&organizationId" (Check second image) So I created a new project, and on the Oath consent screen I fetched the OAuth 2.0 client ID.

So basically I have tried both the client ids(first image and second image)

    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(String.valueOf(R.string.google_default_web_client_id))
            .requestEmail()
            .build();

but in the below code, while retrieving the google sign in account, i get the "com.google.android.gms.common.api.ApiException: 10" exception. Can anybody tell where im going wrong. I tried the answer "Firebase UI authentication with google fails with message (code:10 message:10)" but my issue prevails.

 @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        //if the requestCode is the Google Sign In code that we defined at starting
        if (requestCode == RC_SIGN_IN) {

            //Getting the GoogleSignIn Task
            Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
            try {
                //Google Sign In was successful, authenticate with Firebase
                GoogleSignInAccount account = task.getResult(ApiException.class);
                //authenticating with firebase
                firebaseAuthWithGoogle(account);
            } catch (ApiException e) {
                Toast.makeText(LoginActivity.this, e.getMessage()+e.toString(), Toast.LENGTH_SHORT).show();
                Log.d(TAG, "onActivityResult: "+e.toString()+"  "+e.getLocalizedMessage());
            }
        }
    }
Shikhar
  • 628
  • 1
  • 9
  • 18

0 Answers0