允许通过 API v3 访问 Google 服务帐户 YouTube 上传访问权限 [英] Allowing Google Service Account YouTube Upload Access via API v3

查看:17
本文介绍了允许通过 API v3 访问 Google 服务帐户 YouTube 上传访问权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在没有用户参与的情况下自动将视频上传到 YouTube,所以我创建了一个服务帐户,跳过了障碍,一切看起来都很棒,然后尝试上传,第一个块,我的代码因 Google_Exception 异常而爆炸:

无法启动可恢复上传(HTTP 401: youtube.header, Unauthorized)"

然后我在 YouTube API v3 上挖掘发现错误信息:

https://developers.google.com/youtube/v3/docs/errorsp>

如果您尝试使用 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 上传访问权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆