2

I am using Ionic 2 with GooglePlus Authentication. Everything works perfectly for iOS. For Android I build my app as follows:

ionic build android

For the Android build, I need a SHA1 keystore for Google Authentication.

I have a Macintosh HD/Users/myname/.android/debug.keystore, so according to these instructions, I generate a keystore using (default password 'android'):

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

The output looks correct. I use this SHA1 to for my Android Credentials as per the above instructions:

enter image description here

But when I try login, I get: error = 12501

From here I believe it's related to not having the SHA1 in the Google Credentials matching the SHA1 for the Android build of the app.

Question

What SHA1 is my Android build using? How do I check if it matches the one generated above for the credentials?

UPDATE

From reading the following:

enter image description here

I understand it, that for Android, we need to put the SHA1 here:

enter image description here

However, after trying this, I still get the 12501 error.

UPDATE

I have also tried following these instructions, specifically the Android Setup, but I think it's outdated. But they do say the following:

If you get Error 12501 - User Cancelled, this means you used the wrong Bundle ID during your iOS/Android configuration steps. Make sure you are using the correct one, by setting your desired Bundle ID in your config.xml, and using that ID during the Device Setup

As you can see from the image above, the Package name matches the Bundle ID in config.xml.

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.ionicframework.thewhozooXXXX" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
Richard
  • 8,193
  • 28
  • 107
  • 228
  • If you are using the Google Sign-In Cordova/PhoneGap Plugin then you may need to read the section [before you proceed](https://github.com/EddyVerbruggen/cordova-plugin-googleplus#before-you-proceed) the author mentions that you may get `12501` error if you do not edit the package name in `config.xml` – Michael Doye Mar 10 '17 at 12:30
  • Thanks. I am away from my computer right now but will test later. Question: if I have 2 credentials (iOS & Android), which client ID do I use in the config.xml? I read that I should use the iOS one, because Android doesn't look at it. Is that correct? – Richard Mar 10 '17 at 12:55
  • If I understand you correctly, for hybrid apps (ios + android) you will actually only use _one_ client id, this will be the client id provided by google (from google dev console). You can read the ["IMPORTANT" section in the docs](https://github.com/EddyVerbruggen/cordova-plugin-googleplus#4-installation-phonegap-cli--cordova-cli) for more info on this. – Michael Doye Mar 10 '17 at 13:04
  • When you talk about the `'package name'` in the `config.xml`, is that the `widget id`? My `widget id` is equal to the `Package name` in the credential set up for the OAuth Client. Also this equals the `package` in the `AndroidManifest.xml` file. – Richard Mar 10 '17 at 14:21
  • Yeah, the widget id. If they are the same and you still have the problem, then I am not too sure what the issue is, I will be implementing this plugin in one of my apps this weekend and to be honest I am not looking forward to it, set up seems quite tedious. If I get it working, I can ping you here to let you know the steps. – Michael Doye Mar 10 '17 at 14:29
  • Thank you, I appreciate it. If I manage to fix the issue, I will put the answer here, it may help you if you have the same problem. – Richard Mar 10 '17 at 14:31
  • Great, thanks! Just saw on the docs as well - you need to add the Release build certificate fingerprint to google console. That may be the cause of your issue if you are using the debug fingerprint – Michael Doye Mar 10 '17 at 14:34
  • Do you need both a release and debug certificate? I thought you could have one or the other? – Richard Mar 10 '17 at 14:36
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/137764/discussion-between-und3rtow-and-richard). – Michael Doye Mar 10 '17 at 14:37

2 Answers2

1

SOLUTION

You need to use a Web Client ID and not an Android Client ID for Android (Go Figure!). This worked for me.

enter image description here

code:

        GooglePlus.login({
            'webClientId':'XXXXXX.apps.googleusercontent.com',
            'offline': true
        }).then(googleData => {

What I do not understand however, is that for iOS it works with the iOS Client id. So there's no consistency.

UPDATE

This seems to work for Android using the Web client. If you look at the return value googleData:

googleData.providerData[0].displayName 
googleData.providerData[0].photoUrl
Richard
  • 8,193
  • 28
  • 107
  • 228
  • The above seems to work for Android. But for iOS, I get the following issue: http://stackoverflow.com/questions/42736623/google-firebase-authentication-no-displayname-or-photourl-for-ios – Richard Mar 11 '17 at 15:04
0

For future references so it might help others like me:

My problem was the scope parameter:

{
    'scopes': 'email https://www.googleapis.com/auth/admin.directory.resource.calendar',
    'webClientId': 'XXXXXXXXXXX',
    'offline': true
}

It is a SPACE seperated list (I used comma seperated). Comma seperation (or any other than space seperation) will result in 12501.

Maurice Müller
  • 1,312
  • 3
  • 16
  • 32