EddyVerbruggen / cordova-plugin-googleplus

:heavy_plus_sign: Cordova plugin to login with Google Sign-In on iOS and Android
566 stars 626 forks source link

problems signing in 12501 when doing ios + android dev #327

Open cpup22 opened 7 years ago

cpup22 commented 7 years ago

I noticed I can get the plugin working great on android and then I test/run/build my cordova app for ios (where it works fine on ios) then when I go to run/build on android I get the 12501 error. Only way to solve is to uninstall the plugin and reinstall. Which can be frustrating when developing for both platforms constantly having to uninstall/reinstall the plugin.

limaneto commented 7 years ago

have you fixed that ?

JohnMcAvinue commented 7 years ago

I'm getting this on Android as well. I've tripple checked (and then some) that I've followed the instructions but I have to say that they're a bit confusing.

Here's what I've done:

  1. Generated a new Keystore in Debug & Release
  2. Created a new project in Firebase. I am absolutely certain that the SHA-1 entered in Firebase is that which is on the debug Keystore
  3. The Id in the config.xml is the same package name that I have entered in Firebase
  4. I have tried using the Client Id of the "Web client (auto created by Google Service)" OAuth client created in Google Credentials Manager when I created the project in Firebase. I have also created a new Web Application client and used that Id as well.
  5. I have used both of these as the webClientId, and both of them in reverse order in the config.xml. I've mixed and matched these combinations but none work.
  6. I have also created a new Android OAuth client using the SHA-1 from the Release Keystore and tried using this in reverse order in the config.xml

I've basically been trying all combinations of what might be described on the Readme but not matter what I do I get a 12501 error code when I try to log in with Android.

On iOS I can login to Google in the window that loads up and allow permissions to the application but I get a 400 error then when the window closes.

Any clarification on what I'm doing wrong would be greatly appreciated!

SilvaCoder commented 7 years ago

@JohnMcAvinue Exactly the same here. I tried all possible combinations in mind.

ilkkanisula commented 7 years ago

@JohnMcAvinue I'm also getting 12501 (SIGN_IN_CANCELLED) error. Maybe it doesn't work with the firebase authentication?

JohnMcAvinue commented 7 years ago

@ilkkanisula That could well be it. You would think the developer would indicate if this is the case though. Have you tried it with the old way?

ilkkanisula commented 7 years ago

This plugin does about the same but uses some firebase sdk methods also: https://github.com/blakgeek/cordova-plugin-firebase-auth-google/blob/master/src/android/com/blakgeek/cordova/plugin/FirebaseAuthPlugin.java

JohnMcAvinue commented 7 years ago

I created new clients for Android and Web Application in Google Credentials Manager (not Firebase) and tried with those but still getting a 12501. This is almost certainly an issue with the plugin or documentation as I cannot get it to work

ilkkanisula commented 7 years ago

Anyone got this working yet?

SilvaCoder commented 7 years ago

Nope, i had to use the "web" way of doing that.

If anyone wants to jump over this issue and implement he "web" way of getting this done, for futher work on the real solution just hit me and i'll help, or post a demo working properly.

SilvaCoder commented 7 years ago

But i want to say that im starting to think this native G+ SignIn will work only after signing the app and sending it to production/publishment.

JohnMcAvinue commented 7 years ago

I've luckily been able to park this feature for now, and am hoping the developer can come back to help us with this until I actually need it. No point in doing the Web way cos Google are depreciating it in a few months

SilvaCoder commented 7 years ago

@JohnMcAvinue What? Google cant deprecate the web G+ Sign In. What i heard, and indeed the Google did, was not allowing a webview handle signin procress anymore. But i could get around this easily. It does not make sense remove the web signin cause sites will still have this feature on.

JohnMcAvinue commented 7 years ago

@SilvaCoder Yes I thought you were talking about OAuth using InAppBrowser which is being depreciated

SilvaCoder commented 7 years ago

But im using InAppBrowser with Crosswalk without webview in order to make it work. But yes, the normal procress with InAppBrowser is deprecated, but like i said i could get around this and its working pretty well, cause the only thing that Google did was upload a file, and actually webviews cant handle that, thats how they broke the old normal procress. For now is better than nothing, but im still working in the real solution.

ilkkanisula commented 7 years ago

I have also tried to sign in the app with production key and it's still not working properly.

EDIT:I take it back. I ran the same release signed app again after an hour and it started to work. So it seems there is delay in adding a SHA key to google auth. Now It's working and I get back object with

{ email: ..., idToken: ..., diplayName: ...}
SilvaCoder commented 7 years ago

@ikkanisula Thanks for response ! I'll not jump directly to it then.

ilkkanisula commented 7 years ago

So now it's working fine. You need to sign your app with release key using commands:

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -storepass PASSWORD -keystore your.keystore platforms/android/build/outputs/apk/android-release-unsigned.apk release

zipalign -v 4 platforms/android/build/outputs/apk/android-release-unsigned.apk android-release-signed.apk
JohnMcAvinue commented 7 years ago

I'm using ionic cloud to build and have used my release keystore but it doesn't work.

You would imagine using that would mean it's signed?

John

On 25 Jan 2017, at 19:49, ilkkanisula notifications@github.com wrote:

So now it's working fine. You need to sign your app with release key using commands:

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -storepass PASSWORD -keystore your.keystore platforms/android/build/outputs/apk/android-release-unsigned.apk release

zipalign -v 4 platforms/android/build/outputs/apk/android-release-unsigned.apk android-release-signed.apk — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

sammugg commented 7 years ago

Make sure your release SHA1 is the same as what you've used in the Developers Console to set up your project.

JohnMcAvinue commented 7 years ago

I'm 100% certain it is and the package name matches. See what I've tried a few posts up.

John

On 25 Jan 2017, at 20:13, Sam Muggleworth notifications@github.com wrote:

Make sure your release SHA1 is the same as what you've used in the Developers Console.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

Substractive commented 7 years ago

I managed to get it running did everything like documentation said it was bit tricky in developer console I created oauth web and android version. For android version I followed steps for SHA and package. After creating those two I installed plugin with reversed id of android version of app created in developer console. After installing the app in my .js file in webClientId I put ID of the web app created in google developer console and now it all works. Hopefully this helps.

JohnMcAvinue commented 7 years ago

Which keystore did you use for the SHA1?

Substractive commented 7 years ago

Android debug keystore found in .android folder (on my mac)

SilvaCoder commented 7 years ago

So, just for settle down things about this issue. If you plan to make it work on debug you must sign the app with a labeled debug key and this key must be in firebase app on the place where you can put your cert fingerprint. And in order to make it work in production you must sign the app with a labeled release key and put it on developers console when publishing the app. Is this correct ?

gylippus commented 7 years ago

Just wanted to add here that I was facing the same 12501 errors. I'm using Firebase and it appears that the generated "Web SDK configuration" code for Google Sign-In authorization there did not actually match up with what was in the onsole.developers.google.com OAuth 2.0 client IDs for Web Client. I took the Web Client ID from Google Credentials Manager and replaced the one in Firebase. Everything worked right away after that passing the same one to the plugin in my js.

JarLowrey commented 7 years ago

You can automatically sign a Cordova app when running on your local machine with

cordova run android --release

and adding a build.json file next to your config. xml. If you want to commit this file you can leave out your keystore's passwords and popup will ask you to enter keystore and alias passwords.

Barathwaja commented 7 years ago

i was able to get rid of error 12501.. please give the SHA-1 key correctly ...

1 : create an ionic proj. 2 : after that add the plugin and stuffs given by Eddy 3 : then create android platform and add keystore (if release build) or debug.keystore available in this path %USERPROFILE%/.android/debug.keystore. 4 : google how to find SHA-1 in in debug mode and copy and paste in reqd. proj 5 : finally build apk and it wll work,..

Ross-Rawlins commented 7 years ago

I tried @Barathwaja steps and I still get 12501. I created a debug and a release keystore and then I created two separate projects in google console and neither works. I have re tried the process from start to finish 3 times and its still failing.

sammugg commented 7 years ago

Double check that your project is actually building with the keystore you intend it to. Sometimes, especially when using Ionic and Phonegap, there is a separate debug keystore that overrides if you don't specify exactly which one to use.

Barathwaja commented 7 years ago

Please be sure of SHA-1 coz if that's mismatched it will not work.. Am sure of that @Ross-Rawlins

Ross-Rawlins commented 7 years ago

Hey Guys someone in the cordova slack group told me to use the android client id and not the web client id once I swapped them then it all worked 100%;

reno77 commented 7 years ago

Ok.. finally got it working after 2 hours. You need to use the reversed Android client key in the config.xml and the Web client (auto created by Google Service) key in the window.plugins.googleplus.login call ..

I've created 2 Android client keys in the Google API manager, one for Debug and one for Release, and change the reversed client key in config.xml depending on which version I'm compiling currently.

J-Yen commented 7 years ago

I fixed the problem by specifying the location of the keystore: https://www.webniraj.com/2016/11/21/cordova-changing-the-default-debug-keystore-for-android-applications/

Maurice-Mueller commented 7 years ago

Just to let you (and all following guys) know: I had the same problem because I didn't read the documentation of Eddy well enough. The SCOPES are SPACE SEPERATED, not comma seperated. This also results in 12501.

Daedgomez commented 7 years ago

@reno77 solution works for me.