2

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

Community
  • 1
  • 1
user1537779
  • 2,311
  • 5
  • 28
  • 45

3 Answers3

3

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

I think this will help you

Anklet.
  • 479
  • 3
  • 14
1

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.

Prisoner
  • 49,922
  • 7
  • 53
  • 105
  • Could you shed some light here: http://stackoverflow.com/questions/23010509/login-to-google-on-a-web-service-and-use-the-credentials-on-an-android-device – Skynet Apr 11 '14 at 10:53
1

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()
BrettJ
  • 6,801
  • 1
  • 23
  • 26
  • Isn't `getAccounts()` good to go with? where I can get gmail ids, so that i can use them to get the Access Token and then details. Because i tried it and i never needed any `PlusClient`, So, probably no chance of asking for a `Google+ profile`? It will be great if you can confirm on this :) – user1537779 Mar 08 '13 at 04:48
  • 1
    Because my major problem now is **If a Gmail Account doesn't have Google plus profile, it asks to create one. Which shouldn't happen. Gmail alone must be enough to get the Access Token and profile details** – user1537779 Mar 08 '13 at 04:51