Open zigzag-way opened 8 years ago
Looks similar to https://github.com/EddyVerbruggen/cordova-plugin-googleplus/issues/5
Hey @zigzag-way,
I just merged a significant PR the other day that updated the Android side to use Google Sign-In and refactored plugin usage. The current documentation is up to date with those changes. You should check it out. To install it, use the second (GitHub URL) method found in the README.
Let me know if you have any questions!
Happy Coding, ~Sam P.S. If your issue gets resolved, please close it!
Now I updated plugin and "google repository" from Android SDK manager it always returns "12501" error wich is the same (user cancelled).
@marianoarga did you install the plugin from GitHub? This issue should have been resolved in the latest code (which is not on NPM yet).
@sammuggPS Yes, and followed the "keytool SHA1" steps, since they where not needed before, used "android-debug.apk" name in google console, used the SHA1 keytool gave me for the debug app...
The only thing I removed was this line from installation command.
-variable REVERSED_CLIENT_ID=myreversedclientid
Even the demo app is returning the same 12501 error.
@zigzag-way Do you have any updates, did it work after updating the plugin?
@marianoarga The demo app has not been updated... sorry. That's not something I got around to doing.
The reversed clientId is only needed for iOS. If you are only developing for Android, you don't need to include it.
@sammuggPS Yep, that's why I did not include that on the install line, I'll be keep on trying and looking foward to see what happen to @zigzag-way project. Thank you, really apreciate your efforts.
@zigzag-way and @marianoarga,
I was just looking at another thread I was working on, for issue #190, and was reminded of one reason why you could be getting the 12501 issue:
The Client Id you pass in to the login and trySilentLogin needs to be from the WEB app credentials of your project, not the Android client id.
This is very important! Please try it out and let me know what happens.
@sammuggPS I think i'm using the correct ones, the ones you see in this URL (having selected the project previously) https://console.developers.google.com/apis/credentials/oauthclient
You may see the Google console like I see it here: http://www.awesomescreenshot.com/image/1140931/022d1da815bcf2aa8c78e843378f8584
@marianoarga, That is not the clientId you want. You need the one for your WEB application, not Android.
Ok, I'll give it a try, but I don't really understand why I need to submit the keytool's SHA1, since I'll not use that key from the Android app credentials... Wil keep it up and let yu know.
Think about it this way: A Cordova or Phonegap application has two parts, native and hybrid.
This plugin let's you authenticate using the native side. To authenticate a native Android App with Google you have to set up the app credentials. Android apps are recognized using the SHA1 fingerprint, which gets encoded into the installed package.
On the other hand, the hybrid side is running in a webview on top of a native application. Therefore, it is somewhat decoupled from the native side. If you need an access token and/or refresh token you should treat the webview as if it were a server, using a serverAuthCode to get those tokens to use for that session.
Remember, the webview doesn't persist data the same way that the native side does, so those tokens aren't going to be there the next time you start the app up. This is why we take advantage of the decoupled native and hybrid code. We let the native code manage the Google user and use the info we get back from it to do stuff in the hybrid code.
I strongly urge you to dive into Google's Sign-In documentation and learn about all this. They will explain it much better than I, and you can see where I'm getting all these concepts from!
I see, I understand that now. I have been testing with the same results (12501)
I'm using the webclient key. http://www.awesomescreenshot.com/image/1141231/e01963d86fc65e50908ddca3ca4f1dec
This is the portion of code I'm using, it fires automatically after "deviceready"
function login() {
window.plugins.googleplus.login(
{
'scopes': 'profile',
'offline': false,
'webClientId': 'xxxxxxxxxxxxxxxxx.apps.googleusercontent.com'
},
function (obj) {
console.debug(obj);
},
function (msg) {;
console.debug(msg);
}
);
}
I have added the android-debug.apk debug cert (~/.android/debug.keystore) SHA1 to google console in order to use that debug certificate, I have tried the production one too with the same results. http://www.awesomescreenshot.com/image/1141323/1bfed0e59d64e69a42f5912d1f18e38b
@sammuggPS So you are saying that we should use web credentials and not the native android credentials? The reason I am asking is that I am using web client id and still getting the error..
@marianoarga any luck.. did you make it work? @zigzag-way You have been silent for some time did you have any luck with this plugin?
@SidharthPHariharan No, I didn't
@SidharthPHariharan, Yes you need to use the web credentials not the native android credentials. This is specified in Google's documentation for getting an idToken
and serverAuthCode
.
Hello, First of all, thanks for writing this wonderful plugin. I can confirm that this is in fact an issue but only with the latest GIT version of sourcecode. To make things more clear, here's what I did: 1) I correctly used sha1 generated from keytool 2) I used webkey for webClientId 3) I used the latest version and got error code 12501 4) cordova plugin remove cordova-plugin-googleplus 5) cordova plugin add cordova-plugin-googleplus (NPM version) 6) Now I am able to see the google permissions dialog
can you please look into the latest fixes? thanks
@marianoarga very sad.. @sammuggPS great.. this is what I am using
window.plugins.googleplus.login(
{'scopes':[ 'userinfo_profile']},
function (user_data) {},
function(msg){
// this is where the control arrives after selecting the google account from popup
});
why am I getting user cancelled even now? I am using the cli installation. The git version is clashing with existing plugins..
@SidharthPHariharan, The only thing I can see is that you are not passing in your scopes properly. They need to be passed in as a space separated string. For example, scopes: 'profile email'
.
We are aware of the git version clashing with other plugins...And we're not completely sure why. Is it the phonegap facebook plugin? or cordova-plugin-facebook? If so, you're not alone.
@sammuggPS changing the scope did not work as well. The clash was with google play services, I know its deprecated but another plugin requires it so its unavoidable. Please help me with this asap.
@SidharthPHariharan Please avoid using words like ASAP in a collaborative community.
Just for adding some data, the list of plugins I'm using:
cordova-plugin-console 1.0.2 "Console" cordova-plugin-contacts 2.0.1 "Contacts" cordova-plugin-device 1.1.1 "Device" cordova-plugin-fullscreen 1.1.0 "cordova-plugin-fullscreen" cordova-plugin-globalization 1.0.3 "Globalization" cordova-plugin-google-analytics 0.8.1 "Google Universal Analytics Plugin" cordova-plugin-googleplus 4.0.9 "Google+" cordova-plugin-sim 1.2.1 "SIM" cordova-plugin-whitelist 1.2.1 "Whitelist" phonegap-plugin-push 1.6.1 "PushPlugin"
@marianoarga ok(for not using asap as you have received some appreciation there :+1: ) but as I said another plugin requires google play services plugin and thats causing the problem with the git version of this plugin.
@sammuggPS , Any luck investigating this issue? I have been cracking my head since yesterday but no luck. Happen to visit this S/O url http://stackoverflow.com/questions/33583326/new-google-sign-in-android it says about using 2 API keys To quote: Android client key will go inside the google-services.json, and the web application key needs to be set in the requestIdToken or requestServerAuthCode methods.
Am i suppose to follow this?
@getcarpool, Yes, you need to pass the Web App client ID, not the Android or iOS client IDs, in to the googleplus.login function.
Also, an API Key is a different value than the Client ID. You need to pass in the Client ID so the plugin can request an idToken and serverAuthCode.
@sammuggPS Thanks for your response. But I am afraid, that's exactly what I am passing. I am pretty sure I am following each and every step to the letter. Still no luck. I am consistently getting 12501, even though it allows to pick a account from the list but immediately fails.
Here's the way I finally made this right after a head scratching day.
2.update you android sdk to the latest and remove the old one, and if using ionic remember to ionic platform remove android and add it back again to clean the cache currently the android sdk is 6.0
good luck
thanks @sammuggPS for your great work
I am just on the edge of re-implementing a plugin of my own 😄
@davyzhang, That's awesome! Thank you so much for adding that to this conversation. Hopefully that will help some people out!
@davyzhang Are you talking about re-signing the debug apk right? or even the PROD build should be re-signed?
Now getting 12501, let me know if you get any luck @getcarpool @sidharthancrt , etc.
so far as I can tell, two things can give 12501 error
but you might check he using the web application id not the oauth client id to get idToken
google has very poor documentations about error codes, :disappointed:
Sorry I was not able to look into this for quite a while. @marianoarga , yes I am still getting 12501. I am using web app client ID and I have re signed the app. only thing I am yet to do is update my SDK. will let you know the result as soon as I get it done
Hi @marianoarga, I tried to make this work but couldn't. so I have switched to the NPM version again. we could get rid of the ugly 12501 but again we were getting error "Failed to retrieve token" After followed the steps mentioned in issue number 28 to sign the app and installing the signed app (including updating google console with the new signed sha1 key), We are now successfully getting the serverAuthToken. Hope this helps
Hi @marianoarga @davyzhang @sammuggPS
My Application was given 12501. After that I follow the steps given by @marianoarga to signed app. After that I getting error 10 ?
Can anybody help me ?
Hi @sammuggPS,
When I am adding latest plugins from github. with client id like this
cordova plugin add https://github.com/EddyVerbruggen/cordova-plugin-googleplus --variable REVERSED_CLIENT_ID=53379210000-q1pb8a08heitun92b3u5nlh09fkbsole.apps.googleusercontent.com
without passing scope and webclientid like
window.plugins.googleplus.login(
{
},
function (user_data) {
// For the purpose of this example I will store user data on local storage
GoogleUserService.setUser({
userID: user_data.userId,
name: user_data.displayName,
email: user_data.email,
picture: user_data.imageUrl,
accessToken: user_data.accessToken,
idToken: user_data.idToken
});
$ionicLoading.hide();
$state.go('tab.chat-detail');
},
function (msg) {
alert(msg);
$ionicLoading.hide();
}
);
With release version of .apk with signed version. Its working fine on Moto E but not working on Letv mobile.
In Letv its giving Error code 10.
May I know what is the reason ?
But when I passing scope , webclientid then in both device its showing 12501 Error. Like
**window.plugins.googleplus.login(
{
'scopes': 'profile email',
'webClientId': '53379210000-q1pb8a08heitun92b3u5nlh09fkbsole.apps.googleusercontent.com',
'offline': true,
},
function (user_data) {
// For the purpose of this example I will store user data on local storage
GoogleUserService.setUser({
userID: user_data.userId,
name: user_data.displayName,
email: user_data.email,
picture: user_data.imageUrl,
accessToken: user_data.accessToken,
idToken: user_data.idToken
});
$ionicLoading.hide();
$state.go('tab.chat-detail');
},
function (msg) {
alert(msg);
$ionicLoading.hide();
}
);**
I couldn't manage this to work. Moved to Facebook Login. Thank you all for your support.
After struggling with this plugin around 2 days . Moved to Oauth based authentication system for google plus.
Many problem faced with plugins some time conflict with facebook plugins, some time this plugins works and some time not with same device, Plugins not support all devices. Not understand what's issue.
Hey all,
Sorry I haven't responded in a while. My responsibilities at work picked up quite a bit recently.
To those of you using Ionic, I want you to know that I'm working on a POC to see if I run into any of the same issues. I'll start a separate thread with more info when I get things moving.
Thank you for continuing to talk to one another and collaborating! That's the awesome part about Open Source materials.
~~Sam
@sammuggPS Any update on this? I'm working on ionic. I removed fully Android SDK then reinstalled Android SDK 6.0. I created Android Key on the Google Developer Api Console using the SHA1 of my debug keystore
But I keep having error 12501 :(
@alexislg2 Something that someone pointed out recently is that you need to make sure that you are using an emulator that includes the Google APIs (not all of them do). I updated the troubleshooting section of our documentation to reflect that.
If you are running on a device and still getting the 12501, make sure that you are using a Web Application type clientId. Retrieving an idToken and/or serverAuthCode requires this one, not the one for Android devices.
thank you for that answer
Yes I'm working on a real device and I use the same idToken I used with $cordovaOauth. It's working nice with $cordovaOauth (with awful UX) but got 12501 with your plugin.
Hello, @alexislg2 I have the same issue. I'm trying to use this plugin instead $cordovaOAuth and also getting error 12501. I've checked Web Application client id in the Google Console. I'm also working on real device. Did you make it work?
No sorry. Glad to know I'm not the only one ;)
On Tue, Jul 12, 2016 at 1:05 PM, Pavel Lazarenko notifications@github.com wrote:
Hello, @alexislg2 https://github.com/alexislg2 I have the same issue. I'm trying to use this plugin instead $cordovaOAuth and also getting error 12501. I've checked Web Application client id in the Google Console. I'm also working on real device. Did you make it work?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/EddyVerbruggen/cordova-plugin-googleplus/issues/165#issuecomment-232008388, or mute the thread https://github.com/notifications/unsubscribe/AHkMmPjmbbnKjEFESypSmXQehXI1j9D9ks5qU3UMgaJpZM4G7VVK .
@alexislg2 and @ramzed,
Can you send me a snippet of how you're calling the login method? (make sure you sanitize it: block out or replace clientId and other sensitive info)
Sure:
$scope.googleLogin = function () {
$ionicLoading.show({
template: 'Logging in...'
});
window.plugins.googleplus.login(
{
webClientId: settings.GOOGLE_ID, // something like '3746....84-s69aa......8vom...2.apps.googleusercontent.com'
scopes: ['https://www.googleapis.com/auth/userinfo.email',
'https://www.googleapis.com/auth/userinfo.profile']
},
function (user_data) {
console.log(user_data);
$ionicLoading.hide();
},
function (msg) {
$ionicLoading.hide();
console.error(msg);
}
);
};
Just a precision I had to change the plugin.xml file so that I can build, like explained here: https://github.com/EddyVerbruggen/cordova-plugin-googleplus/issues/252#issuecomment-229954529
1) You don't need to input the profile and email scopes. Those are requested by default.
2) Were you to provide additional scopes, they should be a space-separated, string list. Not an array. For example: "<scope1> <scope2>"
3) Did you install the plugin from npm or from github?
Using incorrect scopes gave me 12501 too, even using these: EMAIL PLUS_LOGIN
which are supposed to be ok
@matheo, you should be using the scopes for the Identity Platform (https://developers.google.com/identity/protocols/googlescopes).
Once again, email is requested by default. You do not need to pass that in.
If you want to request PLUS_LOGIN, try "https://www.googleapis.com/auth/plus.login"
.
When I`m using your plugin on my Nexus 4 it always return "user cancelled" error as a result of login (error callback). But it works fine on my Xiami phone. Here is the code: $window.plugins.googleplus.login( { offline: 'true', webApiKey: WEB_API_KEY }, function (user) { serverAuth(user); }, function (msg) { $cordovaDialogs.alert('Google Plus login error. Please try again later', 'Login Error', 'OK'); } );