1

Goal

I am currently working for a company where I need to access the People API from Google Cloud (for which I have set up OAuth) and also utilize Firebase's Analytics

Problem

I get this error:

google_sign_in plugin:PlatformException(sign_in_failed,com.google.android.gms.common.api.ApiException: 10: , null)

when I try to get access to the People API via OAuth. This happens only when I specify the dependencies for google play services in the gradle files (app and project level) [Check SDK Instructions for Firebase Android Project.].

Things I tried

  1. Giving all of the possible SHA keys for the app in the Google Cloud's credentials tab from this answer
  2. Given support email for OAuth
  3. Tried getting rid of the google play services dependencies from gradle files, this did solve the google_sign_in issue but Firebase Analytics stopped working and I get this error:

Missing google_app_id. Firebase Analytics disabled. See shortened_link_that_I_cant_post

Conclusion

Right now I am stuck with using only one of the two services. I removed Firebase from my Project and my App from Firebase console for now.

Packages Concerned

  1. google_sign_in: ^5.4.3: https://pub.dev/packages/google_sign_in
  2. extension_google_sign_in_as_googleapis_auth: ^2.0.7: https://pub.dev/packages/extension_google_sign_in_as_googleapis_auth
  3. googleapis: ^10.0.0: https://pub.dev/packages/googleapis
  4. firebase_core and firebase_analytics
Daniel Chettiar
  • 143
  • 1
  • 10
  • Have you tried to "Safelist Client ID's from External Project" under Firebase->Authentiication->Sign-In Method->Google? There is also the option to migrate users from the other project into your new one: https://firebase.google.com/docs/auth/admin/import-users – sleepystar96 Jan 27 '23 at 06:13
  • @sleepystar96 Hey, thanks for your comment. Do I need to do this even if I am not authenticating from Firebase? I am not using Firebase for user-related tasks, only for basic analytics. – Daniel Chettiar Jan 28 '23 at 06:04

1 Answers1

1

if you have apply plugin: 'com.google.gms.google-services' inside android/app/build.gradle you comment this and it may solve the problem for you. I don't know if it will have a big effect on Firebase, but this solves the problem.

You can read the docs https://firebase.google.com/docs/projects/multiprojects and search Deleting apply plugin: 'com.google.gms.google-services' from your app build.gradle

Update 1: I found if you add at first or replace in oauth_client inside google-services.json at client_id where client_type=3 with web platform Google cloud credentials oauth client id, you can keep apply plugin: 'com .google.gms.google-services', google services code will generate google service values.xml with default_web_client_id attribute as your web client id, then this solves the problem.

Update 2: After reading google_sign_in carefully.

  • I found that you can set serverClientId according to web platform Google cloud credentials oauth client id and google_sign_in will not get default_web_client_id in file google-services values. xml. this solves the problem without changing google-services.json or commentapply: 'com.google.gms.google-services'
  • Or you can remove client_id where client_type = 3 in oauth_client in google-services.json and not have to set serverClientId

Update 24/05/2023: if you need read idToken when sign_in. You should to do Update 1

  • Thanks, I am not longer working on the project but by far your answer seems very helpful in understanding why I was messing up. – Daniel Chettiar Apr 28 '23 at 09:43