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(); } }
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 :
Gradle (From Right Side Panel, you will see Gradle Bar)Tasks Android signingReport (You will get SHA-1 and MD5)2. Add new credentials to API Console
OAuth Client ID Android client (for debug) (example)SHA-1 debug key3. Add your key to your Firebase project :
Go to Project settings -> SHA certificate fingerprints -> Add SHA-1 key of debug app.
Then you can update your google-services.json file in your Android project.
It's works for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With