Login using Gmail credentials

旧街凉风 提交于 2019-12-24 03:27:48

问题


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


回答1:


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

I think this will help you




回答2:


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()



回答3:


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.



来源:https://stackoverflow.com/questions/15271370/login-using-gmail-credentials

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!