简体   繁体   中英

Login using Gmail credentials

Is there a way I can use Google credentials to get basic user info like

Email, Name, Gender

and use them in my application? Its like allowing user to login into my application using Gmail.

I asked the same here .

But the answer says:

You should not use Gmail for user authentication using Google accounts. You can use Google + Sign-in for Android instead. This will allow you to access the user's profile information upon getting the required permissions using OAuth. Check out the guide here:

which i followed and everything worked fine.

But if a Gmail account has no GooglePlus profile, My application asks to create a GooglePlus account. Which makes me think I implemented a GooglePlus Login instead of Gmail Login.

Is the answer for my other question right? Meaning without a GooglePlus profile you cannot have a Gmail Login in Android?

If not how can I have a Google Login in my application?

A similar question here , with no replies.

Please help. Thank You

Try article on this Url : http://nilvec.com/implementing-smtp-or-imap-xoauth-authentication-in-java.html .

I think this will help you

Documentation for using Google's OAuth2 to authenticate a user are provided at https://developers.google.com/accounts/docs/OAuth2Login . As the page notes, however, you and your users get additional features if they use a Google+ account and the Google+ Sign-in, but this is not necessary.

The scopes required are

  • https://www.googleapis.com/auth/userinfo.profile for name and gender
  • https://www.googleapis.com/auth/userinfo.email for the user's email address

Update : I should amend that these scopes are now deprecated, and scheduled for removal. See the URL above for details.

I wouldn't confuse a "gmail" account and a "Google+" account as being different things. Really what you want is for a user to authenticate with their "Google account", which spans many services.

On Android, the easiest way to build authentication with Google accounts is to use the Google Play Services SDK , which includes services like Google sign in.

Google+ documents an end-to-end approach to using Google Play Services SDKs that cover the issues that you asked about by using the PlusClient :

  1. Setting up the client
  2. Getting the user's email address using either PlusClient.getAccountName() or the REST methods.
  3. Getting the user's profile info using the PlusClient.loadPerson()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM