Search code examples
androidoauthopenidaccountmanager

How can I access the Google account user_id?


I'd like to access the user's Google account user_id for authentication, but I don't see any mention of this in the AccountManager.

How can my app request the user_id?


Solution

  • Now that Google Play Services is available, you can use it to request the user's permission to access the https://www.googleapis.com/auth/userinfo.profile scope and, with the resulting access token, make a request to https://www.googleapis.com/oauth2/v1/userinfo?access_token={accessToken} to get their user ID.