EddyVerbruggen / cordova-plugin-googleplus

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

On Android, after successful loin getting only email id in the response #187

Open consrvinfotech opened 8 years ago

consrvinfotech commented 8 years ago

I am using latest version of the plugin i.e 4.0.8. On Android, after successful loin getting only email id in the response. Need display name also in the response.

ingadi commented 8 years ago

Same here. Only getting email in the response. It also doesn't show the Oauth page I customized on the Api manager and the app doesn't appear on the list of connected apps & sites on my Google account.

ricardocarvalh0 commented 8 years ago

Same here, if i pass '{}' to login function i get only email. If i pass a list of scopes it's returning 'no valid token'.

ahmetakin commented 8 years ago

@ricardocarvalh0 @axelingadi @consrvinfotech Hello,

Your issue probably about non signed apk so you should generate signed apk (With keystore which is you create for Google+ API Client ID) for correctly get all information of users.If you haven't created one yet.

Thanks.

ingadi commented 8 years ago

Hi @ahmetakin,

The apk is signed and is on the play store. I am using the same sha I used for the play store for the Google + API. Is this ok?

ahmetakin commented 8 years ago

Hi again @axelingadi ,

Api and Apk package names need to be same.Are they same?

ingadi commented 8 years ago

@ahmetakin yeah they are the same. Same SHA same package name. What's different though is the google accounts. The developer account that I created the credentials for the Google + API is different from the account I use to upload the apk to the play store. Could this be the problem?

ahmetakin commented 8 years ago

@axelingadi if you use 2 different account for Google Developers console and Google Play Developer Console give permission each other.

rajeshkumarbehura commented 8 years ago

I was getting only email id but later figured out that I am missing one step - https://developers.google.com/identity/sign-in/android/start-integrating#prerequisites

click on this link and click Get Configuration File button. Then follow the steps and Enable Google Signin.

Pass the scope parameter as {email profile }

window.plugins.googleplus.login( {scopes: 'profile email'}, function (user_data) { alert("user_data : " + JSON.stringify(user_data)); }, function (msg) { alert("error : " + msg); } );

mdeprezzo commented 8 years ago

I already enabled google signin, but anyways i recieved always the email.

odedkeren1 commented 8 years ago

I had the same thing now, you need to add {scopes: 'profile email'} if that doesnt work for you, look at the package name, I had also 1 capital letter by mistake. and another thing that you can do is also set 'offline': true window.plugins.googleplus.login( { 'scopes': 'profile email', 'offline': true } and then to use the token you receive for approaching other APIS. if you dont receive authToken when sending 'offline': true then you didnt do one of the steps correctly.

take a look at this as well: https://cordova.apache.org/docs/en/latest/guide/platforms/android/index.html#signing-an-app to make sure all environment is setup correctly.

Good luck.

Rajnishkumar184 commented 8 years ago

I tried All these steps after that facing the same issue.

sammugg commented 8 years ago

Hey @Rajnishkumar184, @consrvinfotech, @axelingadi, @ricardocarvalh0, @ahmetakin, @rajeshkumarbehura, @Mdpproduction, and @odedkeren1, thanks for pointing this out!

I just merged a significant update yesterday 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. Let me know if y'all have any questions!

Note that you need to pass an options object in, even if it's empty ({}). The default scopes are Profile and Email.

Happy Coding, ~Sam

P.S. Close this issue if you're good to go!

ingadi commented 8 years ago

@sammuggPS The update fixed this issue for me. Works like a charm. Thanks!

Rajnishkumar184 commented 8 years ago

@sammuggPS, issue is fixed now and working fine. Thanks

Shynka commented 8 years ago

Not, for me. It's saying "ERROR: NO VALID TOKEN"

sammugg commented 8 years ago

@shynka,

Did you update the plugin using the GitHub Url or the npm registry? Did you remove the plugin from your platforms before reinstalling?

If not, please try both of those things and get back to me.

~Sam

Shynka commented 8 years ago

I've been trying for a few days now, remaking the demo app, remaking the credentials, redoing everything. The farest I've gotten is getting just the email.

sammugg commented 8 years ago

@Shynka, 1) Could you please answer the questions from my first reponse? 2) Could you post a snippet of how you are calling the googleplus.login method?

Shynka commented 8 years ago

Sorry, I have tried installing it from github threw the tutorial

sammugg commented 8 years ago

@Shynka, Again, please answer my questions. I need more info in order to be of any help.

Shynka commented 8 years ago

I Created a new phonegap app replaced the index.html with the one in github got the plugin using "cordova plugin add https://github.com/EddyVerbruggen/cordova-plugin-googleplus"

Ran "cordova platform add android" then "cordova prepare" then "cordova build" Installed it with Gapdebug And Clicked "Login with Google+" my accounts pop up and sometimes it shows just my email, and sometimes it shows "ERROR: NO VALID TOKEN"...

I also did all the sha1 things, but when I look in the usage quote, nothing shows up

Shynka commented 8 years ago

I fixed it by releasing the build... which wasn't mentioned any where

sammugg commented 8 years ago

@Shynka, Can you elaborate on what you mean by that?

(P.S. Sorry I wasn't able to get back to you again earlier; got busy with some other stuff)

Shynka commented 8 years ago

I was able to get the demo app to get an error code 12501 which is the unsigned error code. So I when to the build phonegap site and build it as a release with the keystore from the tutorial. After installing it all worked perfectly.

sammugg commented 8 years ago

Ah I see. Very interesting! Glad you got it working and picked up on that nuance.

ahmedwahba commented 7 years ago

using signed apk solved my problem

Rajnishkumar184 commented 7 years ago

getting "error: 10" message in android