Java YouTube 数据 API:无需用户干预即可使用 V3 对服务进行 OAuth 身份验证

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21057358/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 06:14:58  来源:igfitidea点击:

YouTube Data API: OAuth Authentication for services using V3 without user intervention

javaapiauthenticationyoutubeyoutube-api

提问by avillagomez

I'm implementing a service that automatically uploads videos to a YouTube channel once they are uploaded on a different server.

我正在实施一项服务,一旦将视频上传到不同的服务器上,该服务就会自动将视频上传到 YouTube 频道。

When I first started I was using ClientLogin authentication and YouTube API v2.0 – Direct Uploadingand everything worked perfectly. However, since ClientLogin is deprecated, I'm trying to update to use v3.0.

当我第一次开始时,我使用 ClientLogin 身份验证和YouTube API v2.0 – 直接上传,一切都很完美。但是,由于不推荐使用 ClientLogin,我正在尝试更新以使用 v3.0。

I checked this documentationand it assumes that the file is stored locally, which in my case is not, and this service will not be running on my local machine, and I'm not able to get the access token for OAuth 2.0.

我检查了这个文档,它假设文件存储在本地,在我的情况下不是,而且这个服务不会在我的本地机器上运行,我无法获得 OAuth 2.0 的访问令牌。

Can anybody provide guidance?

有人可以提供指导吗?

采纳答案by Ibrahim Ulukaya

You can do so by getting a refresh token from OAuth2 Playgroundand setting it in your youtube object.

您可以通过从OAuth2 Playground获取刷新令牌并将其设置在您的 youtube 对象中来实现。

Here it explains a little more.

这里稍微解释一下。

And a step by step video.

和一步一步的视频。