Google 不同 API 的 OAuth 访问令牌
Google OAuth Access tokens for different APIs
我正在尝试访问报告 API。并在 Java (GitHub project) 上为此创建了源代码。
我可以获得访问令牌,但是如果我将它用于报告 API Google 总是 return 我 "Access denied. You are not authorized to read activity records" 错误。
我尝试使用此访问令牌从云端硬盘 API 接收信息并且它有效。因此,访问令牌对驱动器 API 有效,对报告 API.
无效
我在这个页面上找到了这个信息 - Using OAuth 2.0 to Access Google APIs
Access tokens are valid only for the set of operations and resources
described in the scope of the token request. For example, if an access
token is issued for the Google+ API, it does not grant access to the
Google Contacts API. You can, however, send that access token to the
Google+ API multiple times for similar operations.
所以我不能对所有 API 使用一个访问令牌?如果是这样,我怎样才能获得报告的访问令牌 API?
我正在使用服务帐户 JSON 生成访问令牌。
感谢您的帮助!
亚历克斯
So I can't use one Access token for all APIs?
当您对用户进行身份验证时,您会请求一些范围,这会告诉用户您需要访问哪些 api 和数据。有很多 Scopes 每个范围都可以让您访问不同的数据。
If so how can I get Access Token for Reports API?
您在身份验证代码中包含了 api 的范围。很难知道您在谈论哪些报告 api
还有 Google 分析报告 api 和 Youtube 分析报告。了解您需要包含的范围的最简单方法是检查您正在使用的方法的文档页面,它们将始终包含一个授权部分,告诉您需要哪个范围才能使用它。
我正在尝试访问报告 API。并在 Java (GitHub project) 上为此创建了源代码。
我可以获得访问令牌,但是如果我将它用于报告 API Google 总是 return 我 "Access denied. You are not authorized to read activity records" 错误。
我尝试使用此访问令牌从云端硬盘 API 接收信息并且它有效。因此,访问令牌对驱动器 API 有效,对报告 API.
无效我在这个页面上找到了这个信息 - Using OAuth 2.0 to Access Google APIs
Access tokens are valid only for the set of operations and resources described in the scope of the token request. For example, if an access token is issued for the Google+ API, it does not grant access to the Google Contacts API. You can, however, send that access token to the Google+ API multiple times for similar operations.
所以我不能对所有 API 使用一个访问令牌?如果是这样,我怎样才能获得报告的访问令牌 API?
我正在使用服务帐户 JSON 生成访问令牌。
感谢您的帮助! 亚历克斯
So I can't use one Access token for all APIs?
当您对用户进行身份验证时,您会请求一些范围,这会告诉用户您需要访问哪些 api 和数据。有很多 Scopes 每个范围都可以让您访问不同的数据。
If so how can I get Access Token for Reports API?
您在身份验证代码中包含了 api 的范围。很难知道您在谈论哪些报告 api
还有 Google 分析报告 api 和 Youtube 分析报告。了解您需要包含的范围的最简单方法是检查您正在使用的方法的文档页面,它们将始终包含一个授权部分,告诉您需要哪个范围才能使用它。