简体   繁体   English

如何使用“服务帐户”的Google Oauth2凭据获取用户的电子邮件ID?

[英]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? 如何使用访问令牌获取Google的用户基本信息? Access token which is generated by an service account of Google. 由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? 当我尝试通过使用https://www.googleapis.com/oauth2/v1/userinfo?access_token=xxxx ..来获取用户信息时,该信息将返回服务帐户的电子邮件和服务帐户ID。而这不会返回用户的实际信息email id(anu@gmail.com) ..如何通过此服务帐户访问令牌获取用户的实际电子邮件id( anu@gmail.com )?

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. 假设您要使用的是Google Apps帐户,并且该域已授予您的服务帐户对配置文件范围的权限,则只需要使用sub =参数来设置您想要访问令牌的用户。 Then user profile calls will return data on the user instead of the service account. 然后,用户配置文件调用将返回用户而非服务帐户上的数据。 See delegating domain-wide authority . 请参阅委派域范围的权限

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何为电子表格服务设置OAuth2 Google凭据? - How do I set OAuth2 Google Credentials for Spreadsheet Service? 如何使用hwioauthBundle在oauth2之后获取Google帐户电子邮件地址 - How to get google account email address after oauth2 using the hwioauthBundle 如何使用Javascript从Google Api检索服务帐户OAuth2令牌? - How can I retrieve a service account OAuth2 token from Google Api with Javascript? 如何使OAuth2与服务帐户一起使用 - How to get OAuth2 working with a service account 带有服务帐户的Google OAuth2 - 指定要代表的用户电子邮件 - Google OAuth2 with Service Account - specifying the user email to act on behalf of 在C#中使用google OAuth2后如何获得email? - how to get email after using google OAuth2 in C#? 带有服务帐户的Google协调中心OAuth2 - Google Coordinate OAuth2 with Service Account OAuth2 令牌,消息:'{“error”:“access_denied”}' 在我尝试使用 OAuth(服务帐户)更新 Google 日历时返回 - OAuth2 token, message: '{ “error” : “access_denied” }' returned when I try to update Google Calendar using OAuth (Service Account) 服务帐户的oauth2 - oauth2 for service account 如何从 OAuth2 Google API 获取电子邮件和个人资料信息? - How to get email and profile information from OAuth2 Google API?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM