163

I am trying to integrate Google Sign In into my app. I don't have a back-end server, I am just getting the details of the logged on Google Account to my app.

I first tried it by using Google Sign In Example but I got an error (No code changes made except for printing the stacktrace below). I just used the example SignInActivity as I don't have a back-end server.

 Exception com.google.android.gms.common.api.ApiException: 12500: 
 at com.google.android.gms.common.internal.zzb.zzz(Unknown Source)
 at com.google.android.gms.auth.api.signin.GoogleSignIn.getSignedInAccountFromIntent(Unknown Source)
 at com.ewise.android.api.MainActivity.onActivityResult(SignInActivity.java:89)     at android.app.Activity.dispatchActivityResult(Activity.java:7010)
 at android.app.ActivityThread.deliverResults(ActivityThread.java:4187)
 at android.app.ActivityThread.handleSendResult(ActivityThread.java:4234)
 at android.app.ActivityThread.-wrap20(ActivityThread.java)
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1584)
 at android.os.Handler.dispatchMessage(Handler.java:102)
 at android.os.Looper.loop(Looper.java:154)
 at android.app.ActivityThread.main(ActivityThread.java:6316)
 at java.lang.reflect.Method.invoke(Native Method)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)

Code

 public class SignInActivity extends AppCompatActivity implements
         View.OnClickListener {

     private static final String TAG = "SignInActivity";
     private static final int RC_SIGN_IN = 9001;

     private GoogleSignInClient mGoogleSignInClient;
     private TextView mStatusTextView;

     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_main);

         // Views
         mStatusTextView = findViewById(R.id.status);

         // Button listeners
         findViewById(R.id.sign_in_button).setOnClickListener(this);
         findViewById(R.id.sign_out_button).setOnClickListener(this);
         findViewById(R.id.disconnect_button).setOnClickListener(this);

         // [START configure_signin]
         // Configure sign-in to request the user's ID, email address, and basic
         // profile. ID and basic profile are included in DEFAULT_SIGN_IN.
         GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                 .requestEmail()
                 .build();
         // [END configure_signin]

         // [START build_client]
         // Build a GoogleSignInClient with the options specified by gso.
         mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
         // [END build_client]

         // [START customize_button]
         // Set the dimensions of the sign-in button.
         SignInButton signInButton = findViewById(R.id.sign_in_button);
         signInButton.setSize(SignInButton.SIZE_STANDARD);
         signInButton.setColorScheme(SignInButton.COLOR_LIGHT);
         // [END customize_button]
     }

     @Override
     public void onStart() {
         super.onStart();

         // [START on_start_sign_in]
         // Check for existing Google Sign In account, if the user is already signed in
         // the GoogleSignInAccount will be non-null.
         GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(this);
         updateUI(account);
         // [END on_start_sign_in]
     }

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

         // Result returned from launching the Intent from GoogleSignInClient.getSignInIntent(...);
         if (requestCode == RC_SIGN_IN) {
             // The Task returned from this call is always completed, no need to attach
             // a listener.
             Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
             handleSignInResult(task);
         }
     }
     // [END onActivityResult]

     // [START handleSignInResult]
     private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {
         try {
             GoogleSignInAccount account = completedTask.getResult(ApiException.class);

             // Signed in successfully, show authenticated UI.
             updateUI(account);
         } catch (ApiException e) {
             // The ApiException status code indicates the detailed failure reason.
             // Please refer to the GoogleSignInStatusCodes class reference for more information.
             Log.w(TAG, "signInResult:failed code=" + e.getStatusCode());
             e.printStackTrace();
             updateUI(null);
         }
     }
     // [END handleSignInResult]

     // [START signIn]
     private void signIn() {
         Intent signInIntent = mGoogleSignInClient.getSignInIntent();
         startActivityForResult(signInIntent, RC_SIGN_IN);
     }
     // [END signIn]

     // [START signOut]
     private void signOut() {
         mGoogleSignInClient.signOut()
                 .addOnCompleteListener(this, new OnCompleteListener<Void>() {
                     @Override
                     public void onComplete(@NonNull Task<Void> task) {
                         // [START_EXCLUDE]
                         updateUI(null);
                         // [END_EXCLUDE]
                     }
                 });
     }
     // [END signOut]

     // [START revokeAccess]
     private void revokeAccess() {
         mGoogleSignInClient.revokeAccess()
                 .addOnCompleteListener(this, new OnCompleteListener<Void>() {
                     @Override
                     public void onComplete(@NonNull Task<Void> task) {
                         // [START_EXCLUDE]
                         updateUI(null);
                         // [END_EXCLUDE]
                     }
                 });
     }
     // [END revokeAccess]

     private void updateUI(@Nullable GoogleSignInAccount account) {
         if (account != null) {
             mStatusTextView.setText(getString(R.string.signed_in_fmt, account.getDisplayName()));

             findViewById(R.id.sign_in_button).setVisibility(View.GONE);
             findViewById(R.id.sign_out_and_disconnect).setVisibility(View.VISIBLE);
         } else {
             mStatusTextView.setText(R.string.signed_out);

             findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE);
             findViewById(R.id.sign_out_and_disconnect).setVisibility(View.GONE);
         }
     }

     @Override
     public void onClick(View v) {
         switch (v.getId()) {
             case R.id.sign_in_button:
                 signIn();
                 break;
             case R.id.sign_out_button:
                 signOut();
                 break;
             case R.id.disconnect_button:
                 revokeAccess();
                 break;
         }
     }
  }

From what I read, the issue could be caused by SHA1 Generation.

I followed the complete guide but apparently it's not working.

I copied the SHA1 from gradle signingReport

Variant: debug
Config: debug
Store: /Users/user/.android/debug.keystore
Alias: AndroidDebugKey
MD5: A3:16:3F:43:75:FE:07:62:6D:8D:CC:DD:21:9F:FA:1A
SHA1: 7B:21:26:7F:D8:18:BB:0E:36:1C:82:DD:B7:28:5F:C1:2F:5C:E4:EA
Valid until: Saturday, August 31, 2047
----------
Variant: release
Config: none
----------
Variant: debugAndroidTest
Config: debug
Store: /Users/user/.android/debug.keystore
Alias: AndroidDebugKey
MD5: A3:16:3F:43:75:FE:07:62:6D:8D:CC:DD:21:9F:FA:1A
SHA1: 7B:21:26:7F:D8:18:BB:0E:36:1C:82:DD:B7:28:5F:C1:2F:5C:E4:EA
Valid until: Saturday, August 31, 2047
----------
Variant: debugUnitTest
Config: debug
Store: /Users/user/.android/debug.keystore
Alias: AndroidDebugKey
MD5: A3:16:3F:43:75:FE:07:62:6D:8D:CC:DD:21:9F:FA:1A
SHA1: 7B:21:26:7F:D8:18:BB:0E:36:1C:82:DD:B7:28:5F:C1:2F:5C:E4:EA
Valid until: Saturday, August 31, 2047

what could be the possible cause of this?

Thanks

P.S. Could this be a possible cause?

Google Play services out of date.  Requires 11720000 but found 10932470
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Aaron
  • 2,591
  • 4
  • 27
  • 45
  • Hey can you please post your code – Dilip Dec 04 '17 at 11:59
  • Hi @Dilip I literally used this :) https://github.com/googlesamples/google-services/tree/master/android/signin/app. Updated it anyway – Aaron Dec 04 '17 at 12:17
  • 1
    So what happen you get same error or anything else happen.one thing please make one more time SHA1 manually and put at developer console against your APP and cross check package name and download google-services.json file and put at app level. – Dilip Dec 04 '17 at 12:23
  • Yes @Dilip I get the same error. I crossed checked package name. I even tried using another keystore but the result is the same. – Aaron Dec 04 '17 at 12:31
  • You need to make code changes to get **your** API key. And yes, you should update the play services – OneCricketeer Dec 04 '17 at 12:43
  • What a wonderful question. Thanks for asked. Btw how can i get token? – Erçin Dedeoğlu Apr 26 '20 at 18:53
  • This was the only thing that worked for me, all of the answers talking about SHA-1 keys are usually leading you to an "Upload Key" instead of the app signing key. This is auto created in the play console and this solved my issue: https://stackoverflow.com/questions/64587610/google-sign-in-throws-an-exception-com-google-android-gms-common-api-apiexceptio – Jared Green Sep 06 '21 at 20:38

40 Answers40

238

Error PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 12500: , null)

This 12500 Error can be solved by adding a support email address to your project in project settings. Open link https://console.firebase.google.com/

Select Your project and open settings tab.

Provide a valid support email and restart your application now.

enter image description here

Swaroop Maddu
  • 4,289
  • 2
  • 26
  • 38
  • 15
    Thanks man! This error is pretty cryptic, it can mean any of the stuff that are mentioned in the answers here. My problem was this one :( – Billda May 29 '19 at 10:11
  • 7
    I did everything mentioned in the developer console https://developers.google.com/identity/sign-in/android/sign-in and after spending a day on trying to put SHA-1 fingerprint and all this was the problem. You helped. Thanks a lot! – class Android Jul 02 '19 at 18:55
  • Try adding SHA1 key for your project @RohitSingh – Swaroop Maddu Jul 18 '19 at 11:53
  • cannot find this public settings option? – Fazal Jarral Mar 22 '20 at 04:59
  • @FazalJarral There is a settings icon at the top left next to title Project Overview click on that and select Project settings in the general tab you can find this Public settings option. – Swaroop Maddu Mar 22 '20 at 05:07
  • @MadduSwaroop I have the same issue, but updating email doesn't help at all https://stackoverflow.com/questions/64587610/google-sign-in-throws-an-exception-com-google-android-gms-common-api-apiexceptio – Viktor Apoyan Nov 03 '20 at 10:33
  • @ViktorApoyan try updating SHA-1 fingerprint of app – Swaroop Maddu Nov 03 '20 at 11:03
  • @MadduSwaroop I did also that I even completely removed the firebase project and created a new one, I am not able to use the Sign In button not from debug build not from release. – Viktor Apoyan Nov 03 '20 at 12:27
  • I'm now getting a different error but that's an improvement. Thank you for this answer. – Nagaraj Alagusundaram Jul 12 '21 at 01:49
  • Just adding it here that, I was facing this issue in emulator and things were working on real device – vizsatiz Feb 19 '22 at 06:11
  • release.keystore & debug.keystore are separate files so make sure that you have the SHA1 key for both. – Satish Gaurav Apr 18 '23 at 15:02
55

Check if SHA-1 fingerprints are added to the firebase project settings. If not,find SHA-1 fingerprint using

https://developers.google.com/android/guides/client-auth

Also, find the SHA-1 fingerprint of release key using

keytool -list -v -keystore <keystore path>

Remove <keystore path> with the path of the key store.

Then add both SHA-1 fingerprints to firebase projects settings.

NB: Don't forget to replace google-services.json with updated google-services.json with new fingerprints. I lost two days on that.

While debug

Android studio automatically generate ~/.android/debug.keystore on first debug build and use it to sign the app.

To get the SHA-1 run (password android) (doc):

keytool -exportcert -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore

This SHA-1 should be added to the app settings at firebase to allow usage of google sign in capabilities while testing debug build.

michaelbn
  • 7,393
  • 3
  • 33
  • 46
Niyas Nazar
  • 1,073
  • 13
  • 20
  • 3
    How are you certain he's using Firebase? – PaulG Oct 25 '18 at 17:57
  • Guessed it (similarity in code and serverless). Firebase project is also connected to the GCP console. We can also change fingerprints in GCP credentials. – Niyas Nazar Oct 27 '18 at 07:04
  • same error with, but in my case it was not related to firebase (i'm not using it). – Majed DH Nov 06 '18 at 13:00
  • Go to https://console.developers.google.com/apis/credentials .Add new credential (O Auth Client) with SHA key. (Firebase automatically does this for our firebase projects) – Niyas Nazar Nov 06 '18 at 13:36
  • The google-services.json file can be found in the app directory inside your project. (Go through Finder / File Explorer) – Mehul Tandale Nov 13 '18 at 08:37
  • @NiyasNazar earlier it was working fine, When I changed my laptop it is showing me same error, Then I generated sha-1 from my current laptop and added this in firebase console.. still having same error. signInResult:failed code=12500. if you can help me – Tarun Dec 28 '18 at 06:12
  • @Tarun what about google-services.json. Do you update it with new SHA-1? – Niyas Nazar Dec 28 '18 at 11:33
  • Found the solution , it contained two client_id and I used different 1. Thank you for your answer @NiyasNazar – Tarun Dec 31 '18 at 09:07
  • It promped me to the debug keystore's password, I left it blank and it worked. – Edgar Froes Oct 29 '20 at 23:07
  • adding SHA-1 solved for me (I have added de sha-256 only) – egidiocs Nov 04 '20 at 15:51
55

Support email and also all project and privacy links are necessary for Google SignIn to work, otherwise it throws 12500.

Set it on https://console.developers.google.com/apis/credentials on the bottom of second tab named "OAuth consent screen" - there you'll find three links that need to be configured.

This is not mentioned ANYWHERE in the Firebase guides.

zub0r
  • 1,299
  • 1
  • 14
  • 20
  • 3
    Thanks, it is working for me. I have wasted almost whole days to resolving the problem – krishan kumar Sharma Jul 12 '19 at 13:25
  • 2
    Thanks, I just added one of the 'authorised domains' to the privacy links and everything worked. You saved me some hours of trial and error – jaecktec Jul 15 '19 at 16:42
  • This should be accepted answer. I have been struggling with that 2 days, without any success. Google should update guides, for now their documentation is misleading, their guide will never work and error code tells nothing – user1209216 Jul 18 '19 at 08:07
  • 2
    where to add privacy links? – Shihab Uddin Jul 25 '19 at 11:46
  • 4
    On second tab named "OAuth consent screen" - on the bottom of the form you've got three links – zub0r Jul 25 '19 at 12:14
  • 1
    To set Email and Privacy Policy : Click on "OAuth consent screen" -> Click on "Edit App". Now you can see both options. – Sanjay Kumar Dec 26 '19 at 12:37
  • 1
    Is there an option to generate the policy and privacy links from firebase? – cristi.gherghina Apr 10 '20 at 07:12
  • 1
    @Coco I have the same issue, but the problem that I don't have any personal domain? how I can solve this problem? https://stackoverflow.com/questions/64587610/google-sign-in-throws-an-exception-com-google-android-gms-common-api-apiexceptio – Viktor Apoyan Nov 03 '20 at 10:36
  • @ViktorApoyan I guess buy one? – jaecktec Nov 05 '20 at 15:45
53

 for error 12500 You need to add support gmail in settings of firebase only and for error 10 add ssh fingerprint in firebase console as you see in picture

Vijay
  • 571
  • 4
  • 4
  • good and straight forward answer, Just configured my gmail account and bam it does the rest – Ajeett Jun 05 '20 at 06:38
  • "for error 12500 You need to add support gmail in settings of firebase only and for error 10 add ssh fingerprint in firebase console as you see in picture" This really helped. I was getting 12500, applied SHA1 fingerprint and it still wasn't working. Adding the SUPPORT EMAIL helped. Thanks! – class Android Aug 27 '20 at 09:58
  • @Vijay I have a same issue but adding email address does not solve my problem https://stackoverflow.com/questions/64587610/google-sign-in-throws-an-exception-com-google-android-gms-common-api-apiexceptio Please help – Viktor Apoyan Nov 03 '20 at 10:34
49

Simply update your Google Play Services to the latest version (or 11720000 in this case). If you are using AVD, Nexus 5 and 5X images support Google Play. Once the emulator is up and running, go to the Extended Controls Menu > Google Play then update.

Strauss
  • 737
  • 7
  • 15
21

Try updating the OAuth consent screen on https://console.developers.google.com/apis/credentials

double-beep
  • 5,031
  • 17
  • 33
  • 41
Fauzi Danartha
  • 1,709
  • 1
  • 8
  • 7
20

I was stuck of this for a while.

Make sure these step are performed-

  • Correct SHA key is saved on Firebase Console.
  • Download the latest google-service.json
  • And Last and most important Save OAuth consent under credentials in google api, OAuth Screen This took a long to figure out. And it worked fine after this.
Pranjal Gupta
  • 325
  • 3
  • 4
18

Seems your SHA1 is overwritten by Google play store. Check in your google play store, launch panel, under app signing, see if google play has an additional SHA1 added.

And copy that SHA1, add to your relevant place, would do the job.

  • 2
    oh my god! Thank you for this tip! App Bundles created its own SHA1, so the release keys that are used locally (when generating APKs) isn't the correct one anymore. – Jia Tse Nov 22 '18 at 06:47
  • This is the most confusing workflow ever. But thanks for the tip – DarkNeuron Jun 03 '19 at 11:13
  • Wow. I was looking for this for days. Thank you so much. Worked well. (Ionic/Android). – LacOniC Oct 22 '20 at 23:24
  • Awesome man, I've added the release sha1, but I needed to add this one too – joe06 Jan 25 '23 at 16:35
12

Enable Google Sign in method works for me -Authentication->Sign-in method->google enter image description here

Dayanand Waghmare
  • 2,979
  • 1
  • 22
  • 27
12
  1. Enable Sign-in method GOOGLE.** (not necessary)

enter image description here

  1. Open the project settings.

enter image description here

  1. Provide email for support.

enter image description here

Dharman
  • 30,962
  • 25
  • 85
  • 135
10

In my case, the issue was that my emulator did not have Play Store. I have made the emulator (named API 23) through Visual Studio, because I develop using Xamarin.Forms as well, and in Visual Studio's Android Device Manager you can select if your emulator should have Google Play Store.

Had to create an emulator through Android Studio's AVD and ensure that it had Play Store:

enter image description here

Reed
  • 1,161
  • 13
  • 25
6

If there's still anyone out there with a similar issue, if you're adding custom scopes, make sure it's a valid scope. In my case, I mixed Facebook scopes with Google scopes and took me a while to figure it out!

Paulo Taylor
  • 716
  • 8
  • 18
6

I think the error came from the Wrong SHA1. Please don't forget that the SHA1 is different between release and debug mode in the android studio. Instead of using keytool to get the SHA1, you can use Gradle project -> Task -> android -> signingReport in the android studio (can open it by menu View -> Toolwindow -> gradle ) to get release and debug SHA1. After that, for easy working, you need to create 2 separate credentials with two SHA1 on google cloud console (google just instruct to create 1 using release SHA1, when we develop it will not work since it uses the debug SHA1).

Bioz Nguyen
  • 1,842
  • 1
  • 9
  • 6
6

I'm using Firebase Authentication. My SHA-1 was indicated correctly, client id was also correct but I still was getting 12500.

It turned out that my problem was that I didn't indicate Support email in my project settings. (Settings -> General tab -> Your project (Public settings) section).

algrid
  • 5,600
  • 3
  • 34
  • 37
  • 3
    Same thing happened for me as well. There is serious documentation issues with google's services. I wish they documented such issues or at least show a user friendly error. – ashish-goel Jun 24 '19 at 09:27
  • When a domain is used on the consent screen or in an OAuth client’s configuration, it must be pre-registered here. If your app needs to go through verification, please go to the Google Search Console to check if your domains are authorized. Learn more about the authorized domain limit. anyone knows what to enter here? – Guy Aug 16 '21 at 13:14
  • @ashish-goel this is now documented here: https://firebase.google.com/docs/android/troubleshooting-faq#android-app-error12500 – Rosário Pereira Fernandes May 12 '22 at 18:35
6

In my case, this error was there because android auth was removed by senior team as it seems there's no need of android key in backend authentication. So both Android and Web client keys are needed in google login.

Himani
  • 440
  • 1
  • 6
  • 17
  • 2
    Thanks for this! I also deleted my Android client ID because I thought it's not needed since we only need the web client ID. – zeenosaur Sep 07 '20 at 13:20
5

Go to your project in the Firebase console, open Project Settings, add your SHA certificate fingerprints there. Download the updated google-services.json file and add it to your Projects app folder.

This worked for me.

Firebase console Screenshot

ochs.tobi
  • 3,214
  • 7
  • 31
  • 52
Nishant Rai
  • 101
  • 1
  • 6
4

First make sure you registered your app in the google developers console

Make sure you have both the debug and release keys in your Firebase application. If it this error appears in production, add your SHA-1 release key to fire base app. If it appears in development, then add your SHA-1 debug key.

Where to add SHA-1 finger print

Getting the debug/release key:

keytool -exportcert -list -v -alias [your alias] -keystore [path/to/debug or release.keystore]

Make sure to download the updated google-services.json to your app.

Denn
  • 803
  • 9
  • 19
  • I was failing with GoogleSignInResult.getSuccess() returning false and a code of 12500. Ultimately, it was that someone else had setup my OAuth with their SHA1 instead of my debug key. This fixed it. – Reckless Jan 21 '19 at 17:35
  • @Reckless I'm glad this helped! – Denn Jan 28 '19 at 11:12
4

If you are coming here from flutter : This is one of the corner cases we have to fix as per the documentation here : https://pub.dev/packages/google_sign_in enter image description here

  • Go to Google APIs & Sevices
  • Select the app you want to implement google signin In to.
  • Then click on Enable APIS and Services

enter image description here

  • Then Search for Google Peoples API

enter image description here

  • Open the Google People API card and click enable, your app might get rid of the issue.
erluxman
  • 18,155
  • 20
  • 92
  • 126
4

I tried all of the answers and still was getting 12500. It turned out that the solution for me was even simpler - my project has User Type set to internal and I was trying to log in with email outside of my company. So if none of the previous answers work for you, check if you have User Type set to internal or external and if you try to log in with acceptable account.

enter image description here

Mohru
  • 725
  • 1
  • 7
  • 17
2

For me the problem was using a 'release' ClientID with my debug-configured app. Make sure you have a release and a debug keys, using each SHA-1's respectively.

peresisUser
  • 1,680
  • 18
  • 23
2

When your app authenticates with a backend server or accesses Google APIs from your backend server, then you must pass the OAuth 2.0 client ID that was created for your server to the requestIdToken method when you construct the GoogleSignInOptions object, for accessing the user's basic profile information. Also, don't forget to submit the support email in the OAuth consent screen found in the Credentials page in the API Console.

2

After I tried all solutions above and nothing has worked. I found that I am requesting scope that is not mentioned in the cloud. These is my code

final GoogleSignIn googleSignIn = new GoogleSignIn(
    scopes: [
      'https://www.googleapis.com/auth/userinfo.email',
      'https://www.googleapis.com/auth/userinfo.profile',
      'https://www.googleapis.com/auth/openid',
      'https://www.googleapis.com/auth/youtube.force-ssl'
    ]);

After I removed all scopes, it worked.

My scopes section was empty: enter image description here

Scopes tab can be found here: https://console.cloud.google.com/apis/credentials/consent/edit

1

It can also happen that the cordova compiler is unable to find the proper keystore file.



Solution: Before executing ionic cordova build android specify the signing properties

Step-1: Generate a debug keystore file

Execute the command

keytool -exportcert -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore

Use password: android

Step-2: Copy the keystore file(debug.keystore) from ~/.android to platform/android directory of your current project

Step-3: Create a file named release-signing.properties in the platform/android directory

Step-4: Add the contents in the file

storeFile=debug.keystore
keyAlias=androiddebugkey
storePassword=android
keyPassword=android

Note: These are the default values. If you have provided custom alias and password then use them accordingly.

Step-5: Now build ionic cordova build android

Debojyoti
  • 4,503
  • 3
  • 19
  • 27
1

I experienced the same problem after opening my project on another computer (different Android Studio). In my case, I solved it using the Firebase Assistant, which I had used to setup Firebase initially. Opened the Firebase Assistant (Tools > Firebase) and selecting Authentication > Connect. This reconnected the project to Firebase and updated the configs

allo
  • 11
  • 3
1

I was stuck in the Google Login issue since 2 week, finally sorted it well .let me explain the reason. The issue was related with firebase. In firebase , they mentioned a field "support email " as optional . But once i added it (any of your personal email) ,the issue sorted and i got the response . If your getting an error as 12501 , then it is related to settings in your google account.

Kevin Jose
  • 856
  • 8
  • 22
1

I was stuck of this for a while.

Make sure these step are performed-

Correct SHA key is saved on Firebase Console.
Valid reversed client id.
from fcm console=>select app=>from authentication=>enable google sign-in method
Sumit Kumawat
  • 127
  • 10
1

I know it seems silly but I had this error in my emulator and the issue was resolved when I booted up an emulator that had Google Play API's installed.

Brian Mahecha
  • 189
  • 2
  • 6
0

In my case, it's because of the wrong Google Client Id. I change my key to the key listed in google-services.json (under oauth_client object)

thuanle
  • 330
  • 6
  • 15
0

Make sure you have following things set up properly:

  1. Generate Client Id in your Google Project.
  2. Provide proper SHA-1 key for that Client Id. (debug / release)
  3. Provide proper package name for that Client Id.
  4. Make sure you have generated Client Id in strings.xml, google-services.json or credentials.json file.
Chintan Shah
  • 1,744
  • 2
  • 26
  • 28
0

https://developers.google.com/identity/sign-in/android/sign-in follow this api documentation but keep in mind that inside WEB_CLIENT_ID use the value of client id which is generated inside google-services.json file.

class MainActivity : AppCompatActivity(), GoogleApiClient.OnConnectionFailedListener {
private val TAG = "JSAGoogleSignIn"
private val REQUEST_CODE_SIGN_IN = 1234
private val WEB_CLIENT_ID = "354298333018-XXXXXXXXXXXXXXXXXXXXXXX.apps.googleusercontent.com"
private var mAuth: FirebaseAuth? = null

private var mGoogleApiClient: GoogleApiClient? = null
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)
    var txt_register = findViewById<TextView>(R.id.txt_register)
    txt_register.setOnClickListener {
        var intent = Intent(this@MainActivity, RegisterActivity::class.java)
        finish()
        startActivity(intent)
    }
    val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(WEB_CLIENT_ID)
            .requestEmail()
            .build()
    mGoogleApiClient = GoogleApiClient.Builder(this)
            .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build()

    mAuth = FirebaseAuth.getInstance()
    sign_in_button.setOnClickListener {
        val intent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient)
        startActivityForResult(intent, REQUEST_CODE_SIGN_IN)
    }

}


override fun onConnectionFailed(p0: ConnectionResult) {
    TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}


private fun updateUI(user: FirebaseUser?) {
    if (user != null) {
        Log.e("Email", "Value" + user.email)
    }

}

fun signIn() {

}

override fun onStart() {
    super.onStart()
    val currentUser = mAuth!!.currentUser
    updateUI(currentUser)
}

public override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)

    // Result returned from launching the Intent from GoogleSignInClient.getSignInIntent(...);
    if (requestCode == REQUEST_CODE_SIGN_IN) {
        val result = Auth.GoogleSignInApi.getSignInResultFromIntent(data)
        if (result.isSuccess) {
            // successful -> authenticate with Firebase
            val account = result.signInAccount
            firebaseAuthWithGoogle(account!!)
        } else {
            // failed -> update UI
            updateUI(null)
            Toast.makeText(applicationContext, "SignIn: failed!" + result.status,
                    Toast.LENGTH_SHORT).show()
        }
    }
}

private fun firebaseAuthWithGoogle(acct: GoogleSignInAccount) {
    Log.e(TAG, "firebaseAuthWithGoogle():" + acct.id!!)

    val credential = GoogleAuthProvider.getCredential(acct.idToken, null)
    mAuth!!.signInWithCredential(credential)
            .addOnCompleteListener(this) { task ->
                if (task.isSuccessful) {
                    // Sign in success
                    Log.e(TAG, "signInWithCredential: Success!")
                    val user = mAuth!!.currentUser
                    updateUI(user)
                } else {
                    // Sign in fails
                    Log.w(TAG, "signInWithCredential: Failed!", task.exception)
                    Toast.makeText(applicationContext, "Authentication failed!",
                            Toast.LENGTH_SHORT).show()
                    updateUI(null)
                }
            }
}
Vajani Kishan
  • 293
  • 4
  • 13
0

In my case, After adding fingerprint in Firebase console, it got automatically picked up by the Google developer console and shown the fingerprints. But sign in did not work. After looking at every step, I figured that Google reversed my manifest file package like this com.xxxxxxxx.app. But it is actually app.xxxxxxxx.com, in Google developer console. So I deleted auto created a fingerprint and added fingerprint with the correct package name. BOOM!!. It worked.

Naroju
  • 2,637
  • 4
  • 25
  • 44
0

The error appeared to me when the Google option was not enabled, as shown in image.

It happened when I changed Google's account and forgot to turn on the option of connecting with Google.

Yonibagi
  • 147
  • 10
0

Make sure your project should not contain any special character including numeric or any kind of symbol(project name should be simple as com.google.testproject)

VikasSharmalp
  • 492
  • 1
  • 6
  • 16
0

In my case I was working on a non-production app, the issue was that when creating a project in firebase console, there were issues synchronizing SHA-1 keys back and forth from Firebase & Google developer consoles. So, I decided to create the project first on the Google Developer console, and then select it when creating a new project on Firebase console.

I also made a tutorial for this, that may help you.

Zain
  • 37,492
  • 7
  • 60
  • 84
0

I was facing a similar issue,updating the support email and the OAuth consent screen form didn't work, however adding the Google Play Store App signing key certificate to the Firebase Console Worked:

  1. Copy the App Signing Key from the Google Play Console(Setup -> App Integrity -> App Signing)

enter image description here

Notice that these keys were randomly generated and are not my project's keys.

  1. Add the Keys to Firebase console.

enter image description here

Ivan Bila
  • 747
  • 7
  • 9
0

I think everyone should start debugging by running this before building a release or a debug versions of apps.

flutter clean

everytime you change google-services.json or AndroidManifest.xml files

Nothing worked before I ran this command

Flutter official doc also mention this

 Note: You may need to run flutter clean after changing the gradle file. This prevents cached builds from affecting the signing process.

enter image description here

https://docs.flutter.dev/deployment/android#configure-signing-in-gradle

EDIT: I made it work in both production or development envs. After few days of testing, I encounter this issue again and I was testing different versions of apps installing and uninstalling and upgrading all that stuff. I could not fix it with anything but running flutter clean again.

helloworld331
  • 166
  • 2
  • 9
0

If you have your SHA-1 ready within in your Firebase project settings, you can test your application using a Physical device instead of using an Emulator.

Ahmed Maad
  • 367
  • 5
  • 16
0

What you probably know is that you need to add the debug and release sign in keys of your flutter android app to the Firebase project.

You find the debug key by doing this from your project folder:

stephanedeluca@Angelantonio2019:~/development/OlenPEPS-mobile$ cd android
stephanedeluca@Angelantonio2019:~/development/OlenPEPS-mobile/android$ ./gradlew signingReport
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details

> Task :app:signingReport
Variant: debug
Config: debug
Store: /Users/stephanedeluca/.android/debug.keystore
Alias: AndroidDebugKey
MD5: 4B:7A:AA:...:61:C7
SHA1: 17:B3:67:...:59:EA
SHA-256: DE:2A:E0:...:F1:45
Valid until: jeudi 6 août 2043
----------
Variant: release
Config: release
Store: /Users/stephanedeluca/upload-keystore.jks
Alias: upload
MD5: FC:CD:...:FD:3C
SHA1: D5:F3:...:6A:26
SHA-256: 77:7A:...:67:3F
Valid until: dimanche 26 septembre 2049
----------

As you can see, the debug SHA key sits at the very beginning of the log. Copy it.

Now, go to your Firebase project on the Web and open project settings like so:

Firebase project settings

Scroll down to the keys and tap add and paste the debug key.

enter image description here

Now for the release version: *do not take the one listed at release section: Play store use its own key.

So get to the Play store console and head to the App integrity section as follows; copy the SHA1:

Play store app integrity

Now add it to Firebase the same way you did with the debug key.

And voilà!

Stéphane de Luca
  • 12,745
  • 9
  • 57
  • 95
-1

My solution: (edit: 04/Jan/2019) enter image description here

enter image description here

enter image description here

PhuocLuong
  • 699
  • 9
  • 18
-2

Try this options:

keytool -list -v -keystore C:\Users\MG\Desktop\test.jks -alias test

It prompts for password and just enter password. You can see the SHA1, MD5 fingerprints.

enter image description here

Zoe
  • 27,060
  • 21
  • 118
  • 148
Srini
  • 1