Reputation: 313
I'm looking for a unique identifier for authorized users with oauth2, with scope https://www.googleapis.com/auth/analytics.readonly
.
Without google plus scope https://www.googleapis.com/auth/plus.login
.
At google document reference i found username
field. Description says.
Email ID of the authenticated user
I'm wondering if this field is unique identifier or not. Any knows anything about this?
Upvotes: 1
Views: 214
Reputation: 116918
This is kind of a round about way of doing it but the Management API has a method called accountSummeries.list it returns a list of google analytics accounts the current authenticated user has access to.
It also returns Username which is their email address.
username string Email ID of the authenticated user
{
"kind": "analytics#accountSummaries",
"username": string,
"totalResults": integer,
"startIndex": integer,
"itemsPerPage": integer,
"previousLink": string,
"nextLink": string,
"items": [
management.accountSummaries Resource
]
}
This is the only method I have found that just uses the google analytics API to get info about the user. Alternative is to request profile or email scopes as well and then go though the people API.
Note: You can also decrypt the token id returned by the authentication which will give you Googles internal unique user id. This is a bit harder way of doing it though.
Upvotes: 1