简体   繁体   中英

How can i get an users email id using Google Oauth2 Credentials of ‘Service Account’?

How can I get an Google's user basic information using access token? Access token which is generated by an service account of Google. While I trying to get user info by using https://www.googleapis.com/oauth2/v1/userinfo?access_token=xxxx .. which is returning the service accounts email and service accounts id.. which does not returning the user's actual email id(anu@gmail.com) .. How can I get the user's actual email id( anu@gmail.com ) by this service accounts access token?

Thanks in advance....

Assuming it's a Google Apps account you want and the domain has granted your service account permission for the profile scope, you just need to use the sub= parameter to set the user you want an access token for. Then user profile calls will return data on the user instead of the service account. See delegating domain-wide authority .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM