I am building an app for my company. It has to have a Google sign in feature. However, the company uses a Firebase account for push notifications and crashlytics only and a separate Google Cloud Platform account for Google sign in. This account has an OAuth client registered for Android (SHA1 and package name are correct). The problem is when I try to add requestIdToken(here_is_my_client_id) to GoogleSignInOptions, I only get error with code 10 after the sign in dialog disappear. Without client id everything works well, but for me it is mandatory to use it. I would appreciate any help!
Asked
Active
Viewed 1,650 times
1
XXAAAAAAAXXX
- 41
- 5
-
Check out this answer, https://stackoverflow.com/questions/49450140/google-signin-api-exception-10 – Vaibhav Goyal Aug 31 '21 at 09:21
-
If you registered your SHA-1 certificate correctly then please check client_id which you given in requestIdToken(here_is_my_client_id). – Vatsal Dholakiya Aug 31 '21 at 10:24
2 Answers
3
After some research I've found that you have to pass your web project's Google client id into requestIdToken. I'd been passing Android project's id (from Google Cloud Platform) before.
XXAAAAAAAXXX
- 41
- 5
-
this was the right solution for me to overcome error 10 and be able to get a idToken and other auth info. In google cloud platform interface, click on create new credentials and choose web project (even if using flutter). You can also put this key in strings.xml as suggested in ( https://thomas.trocha.com/blog/google-signin-without-firebase/ ) and you don't need to pass it in your code – Ventosus Oct 27 '21 at 04:26
-
1
Well, you need to create two OAuth 2.0. One (OAuth 2.0 type = Android) to connect with android project using SHA-1 certificate and Second (OAuth 2.0 type = Web application) to get IdToken and AuthCode.
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestScopes(new Scope(Scopes.DRIVE_APPFOLDER))
.requestIdToken(getString(R.string.server_client_id)) // Web application client_id
.requestServerAuthCode(getString(R.string.server_client_id)) // Web application client_id
.requestEmail()
.build();
Vatsal Dholakiya
- 545
- 4
- 19