1

How to get Google User ID something which looks like "1242343543557656",using the GMail address in Android?
I have searched for this and found answers only on, how to get gmail address and the user name.
What I want is the unique id provided by google to a gmail address?

These are some of the links that I have already referred.
-Accessing Google Account Id /username via Android
-How can I get the google username on Android?
-Get the Google ID used to download the application
-How to get the Android device's primary e-mail address

Community
  • 1
  • 1
Amalan Dhananjayan
  • 2,167
  • 1
  • 31
  • 47
  • I am not sure whether this will work or not. But try to look into google sing in button code. It authenticate you and returns your user information like Name,Sex,Profile Pic. It may return the id which you are looking for. Let me know if this works – Hardik Trivedi Nov 15 '13 at 06:34

2 Answers2

0

To the best of my knowledge, you can't get the google user id directly from Android. The only solution is to make an authenticated call to GAE, (i.e. a call with the 'User' parameter) and then read the id from the User object, and then return it to the Android client.

I think the easiest way for you to implement that (since you are using GAE) is to use google endpoints, which quite simplifies the authentication. The instructions and code for doing that authentication are here.

Then call getUserId() on the User object (the first param of your endpoint) and return it to the caller.

Tom
  • 15,404
  • 8
  • 60
  • 70
0

Update as of 2016/12: The Google Identity toolkit has been superseded by Firebase Authentication.

I'm just adding to this question as I see it's gotten a lot of views. The user is required to be authenticated before their Google User ID can be obtained (otherwise you could pull credentials from any arbitrary email address). The recommended way to handle this on Android is to use the Google Identity toolkit:

Use Identity Toolkit in your Android App:
https://developers.google.com/identity/toolkit/android/

Quick-start app for Android:
https://developers.google.com/identity/toolkit/android/quickstart

Adam
  • 5,304
  • 1
  • 16
  • 50