如何授予Google服务帐户对YouTube报表API的访问权限?
我正在尝试使用服务帐户访问YouTube报表API.但是尝试执行youtubeReporting.jobs().list().execute()
时我得到了403禁止.
I am trying to access YouTube Reporting API with a service account. But I am getting a 403 forbidden when trying to do youtubeReporting.jobs().list().execute()
.
YouTube报表API明确假定服务器到服务器的交互.
YouTube Reporting API clearly supposed Server-to-server interaction.
我需要授予Google服务帐户对YouTube报表API的访问权限吗?如果可以,怎么办?
Do I need to grant access to Youtube Reporting API for a google service account? If so, how?
仅供参考:我未使用Google应用程序域.
FYI : I am not using google app domain.
You could create service credentials in the google console, but those credentials won't fix your issue. According to the docs,
服务帐户流支持不访问用户信息的服务器到服务器的交互.但是,YouTube Reporting API和YouTube Analytics API不支持此流程.由于无法将服务帐户链接到YouTube帐户,因此尝试使用此流程授权请求将产生错误.
The service account flow supports server-to-server interactions that do not access user information. However, the YouTube Reporting API and YouTube Analytics API do not support this flow. Since there is no way to link a Service Account to a YouTube account, attempts to authorize requests with this flow will generate an error.
这是p违反直觉的-(更不用说很难找到了)-此信息尤其是.由于在概念上相关的YT API使用服务帐户,请参见此处,以及报告api似乎不需要将操作与特定的用户帐户相关联.
It is p counter-intuitive-- (not to mention hard to locate)-- this info esp. since conceptually related YT APIs utilize service accounts, see here, and the reporting api actions wouldn't seem to need to be associated w/ a specific user account.
不幸的是,如果您将服务帐户用于Youtube Reporting API,您仍然会遇到403未经授权的调用者错误.
Unfortunately, if you use a service account for the Youtube Reporting API you will still end up with a 403 unauthorized caller error.
相反,创建并使用网络客户端Google凭据.存储并使用从流程中生成的令牌.
Instead, create and use web client google credentials. Store and use the token generated from the flow.