根据Google的文档,您应该能够使用服务帐户使用YouTube报告API,而无需用户验证。
目前,我有一个非常简单的示例,可以给我一个可用工作的列表,但可能是空的。但我的403权限被拒绝了。
要求
:
$client = new \Google_Client();
$client->setAuthConfig('service-account-key.json');
$client->addScope(Google_Service_YouTubeReporting::YT_ANALYTICS_MONETARY_READONLY);
$client->addScope(Google_Service_YouTubeReporting::YT_ANALYTICS_READONLY);
$youtube_reporting_service = new \Google_Service_YouTubeReporting($client);
$jobs = $youtube_reporting_service->jobs->listJobs();
回答
:
Google\u Service\u异常
{
"error": {
"code": 403,
"message": "The caller does not have permission",
"errors": [
{
"message": "The caller does not have permission",
"domain": "global",
"reason": "forbidden"
}
],
"status": "PERMISSION_DENIED"
}
}
我验证了已启用以下API:
-
YouTube报告API
-
YouTube数据API v3
-
YouTube分析API
-
Google+API
(如果真有必要,我对此表示怀疑)
我不明白的是,谷歌云平台上的项目与YouTube账户之间的关系应该如何。
这跟
Delegating domain-wide authority to the service account
?
然后是否需要启用G套件?
我看到了一个类似的问题
How to grant access to Youtube Reporting API for a google service account?
存在,但自上次响应以来,该选项可能有点过时。我希望我的样本和补充将为这个问题带来新的曙光。
有人有工作样品吗?可能使用其他语言。只要水流畅通。