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:
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:
I understand it, that for Android, we need to put the SHA1 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">
SOLUTION
You need to use a Web Client ID and not an Android Client ID for Android (Go Figure!). This worked for me.
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
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.
来源:https://stackoverflow.com/questions/42718350/12501-error-ionic-what-keystore-is-the-app-building-with



