Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {
    try {
        GoogleSignInAccount account = completedTask.getResult(ApiException.class); //exception is here

        // Signed in successfully, show authenticated UI.
        System.out.println("google token ---> " + account.getIdToken());
    } catch (ApiException e) {
        // The ApiException status code indicates the detailed failure reason.
        // Please refer to the GoogleSignInStatusCodes class reference for more information about this error.
        e.printStackTrace();
    }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.8k views
Welcome To Ask or Share your Answers For Others

1 Answer

Quoting the documentation:

Certain Google Play services (such as Google Sign-in and App Invites) require you to provide the SHA-1 of your signing certificate so we can create an OAuth2 client and API key for your app.

If you are using Firebase and try on the debug app :

1. First, get your SHA-1 debug key :

  1. Click on Gradle (From Right Side Panel, you will see Gradle Bar)
  2. Click on Tasks
  3. Click on Android
  4. Double Click on signingReport (You will get SHA-1 and MD5)

2. Add new credentials to API Console

  1. Go here https://console.developers.google.com/apis/credentials
  2. Create new OAuth Client ID
  3. Name : Android client (for debug) (example)
  4. Signing-certificate fingerprint : Copy paste you SHA-1 debug key
  5. Put your package name then saved

3. Add your key to your Firebase project :

  1. Go to Project settings -> SHA certificate fingerprints -> Add SHA-1 key of debug app.

  2. Then you can update your google-services.json file in your Android project.

It's works for me.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...