I've been trying to figure out how to use the Google account manager to simply provide a way for users to Login to my app.
I have the AuthToken returning, but how can I get some unique info on the account that won't change for example a uniqueID or something so that I can use it to login the user?
The Account
object you get from AccountManager
has a name
field which is the user's email address. This should be unique since they are all managed by Google and require a password to set up.
Depending on what permissions you asked for when getting the AuthToken, you can query the endpoint https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token=YourTokenHere
and get back a bunch of information about the account.
The response will look something like this:
{
"id": "1234567890",
"email": "[email protected]",
"verified_email": true,
"name": "Joe Mama",
"given_name": "Joe",
"family_name": "Mama",
"link": "https://plus.google.com/1234567890",
"picture": "https://lh6.googleusercontent.com/-abcd/abcd/abcd/1234/photo.jpg",
"gender": "male",
"locale": "en"
}
The id
field here is also unique and has the bonus of being used across Google services.