问题描述
我想在没有用户参与的情况下自动将视频上传到 YouTube,所以我创建了一个服务帐户,跳过了箍,一切看起来都很棒,然后尝试上传,第一个块,并且我的代码炸弹与此 Google_Exception 异常:
无法启动可续传上传(HTTP 401:youtube.header,未授权)"
我随后在YouTube API v3上挖掘并发现了错误信息:
https://developers.google.com/youtube/v3/docs/errors>
如果您尝试使用 OAuth 2.0 服务帐户流程,通常会看到此错误.YouTube 不支持服务帐户,如果您尝试使用服务帐户进行身份验证,则会收到此错误错误."
这是正确的吗?我无法使用服务帐户自动将视频上传到 YouTube?
(浪费了几天的努力!)
是的,是正确的.
前进的道路是进行手动授权并获取生成的刷新令牌",然后将其用于任何自动上传.
确保在执行任何其他操作之前将刷新令牌添加到 PHP Google_Client 对象.
我现在正在自动上传到 YouTube.
I want to automatically upload videos to YouTube without user involvement so I've created a service account, jumped through the hoops, all was looking great, then the upload, chunk one, is attempted and my code bombs with this Google_Exception exception:
"Failed to start the resumable upload (HTTP 401: youtube.header, Unauthorized)"
I then dug and found on the YouTube API v3 error information:
https://developers.google.com/youtube/v3/docs/errors
"This error is commonly seen if you try to use the OAuth 2.0 Service Account flow. YouTube does not support Service Accounts, and if you attempt to authenticate using a Service Account, you will get this error."
Is this correct? I cannot use a service account to upload video to YouTube automatically?
(that was a waste of a couple of days hard work!)
Yes, it is correct.
The way forward is to do a manual authorisation and grab the resultant 'refresh token' and then use that for any automated uploads.
Ensure to add the refresh token to the PHP Google_Client object prior to any other action.
I am now automatically uploading to YouTube.
这篇关于通过 API v3 允许 Google 服务帐户 YouTube 上传访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!