CapacitorGoogleAuth icon indicating copy to clipboard operation
CapacitorGoogleAuth copied to clipboard

Google auth something Wrong response

Open arjunanda opened this issue 2 years ago • 2 comments

I've seen the problem before but couldn't solve this problem

everything has been implemented but for some reason still error on google auth android

What has been stated:

  • client ID creation
  • creation of client ID with sha1 (android)
  • and all implementation has been done

So if there's something I'm missing, let me know

Screenshot from 2022-10-05 08-18-07

arjunanda avatar Oct 05 '22 01:10 arjunanda

any news ?

Which version do you use ?

cprodhomme avatar Oct 14 '22 15:10 cprodhomme

Hello!

I've had a lot of problems while trying to make Google Auth work on Android...I've read a lot of the issues and possible solutions here and after a lot of trial and error, it started working! I'll list a few possibilities for you to check:

  • Make sure you are using your Web Client ID on the configurations...despite the need to have an Android OAuth Client on your Google Console configured with the SHA1 fingerprint of the Keystore with which your app was signed, you won't actually use that Client ID for the authentication process (at least not from the app's perspective - Google probably make the connection between the Web Client ID and the Android Client you have on the same project);
  • For the capacitor.config.(ts | json) file, make sure you are setting the value of androidClientId or clientId within the GoogleAuth plugin configuration. In one of my attempts, I've set only serverClientId, but after looking through the plugin's code I believe the logic is: try to get androidClientId from configs -> if it doesn't have value, try to get clientId from configs -> if it also doesn't have value, use the value of server_client_id from the context (set in strings.xml, for instance);
  • Make sure the URL of your app is set as one of the Authorized Javascript Origins on your Web OAuth Client configurations (during my Android testings, the app was running with the URL localhost - without a port);
  • I'm not sure if this is mandatory, since I've kinda got lost in all the changes I was trying in order for it to work...but I've seen people recommend this (Google also mention this in their documentation): make sure that all fields on the OAuth Consent Screen page are filled (App information, App domain, scopes...)

After I went through all these steps, Authentication is working correctly! I hope yours works as well!

LAlves91 avatar Oct 14 '22 17:10 LAlves91

@LAlves91

Thank you for your attention

it turns out that I forgot one important step, namely entering the debug sha1 in the default android studio, this problem occurred because I directly entered the production SHA1 where I opened the application on the android emulator. I hope others can see this

arjunanda avatar Oct 17 '22 11:10 arjunanda