未经用户同意,使用youtube Data API V3将视频自动上传到我的帐户 [英] Auto Upload of Videos to my account, using youtube Data API V3 without user consent

查看:74
本文介绍了未经用户同意,使用youtube Data API V3将视频自动上传到我的帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Youtube Data API V3通过Oauth 2.0身份验证将视频上传到我的youtube帐户.

I am using Youtube Data API V3 to upload videos to my youtube account using Oauth 2.0 authentication.

 UserCredential credential;
using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read))
{
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
    GoogleClientSecrets.Load(stream).Secrets,
    new[] { YouTubeService.Scope.YoutubeUpload },
    "user",
    CancellationToken.None
);
}

var youtubeService = new YouTubeService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = Assembly.GetExecutingAssembly().GetName().Name
});

在身份验证过程中,它会显示登录和同意"屏幕以显示授权,如图所示

Here during the authentication process it shows up login and Consent screen to get the authorization as shown

Oauth_UserConsent

我需要克服上述问题,以便在未经用户同意的情况下,我希望使用OAuth 2.0对youtube数据API V3进行身份验证并将视频上传到我的帐户.

I need to overcome the above, so that without user consent I want the youtube data API V3 to be authenticated using OAuth 2.0 and do video upload to my account.

因此,我发现服务帐户"可用于这种情况,但又发现服务帐户无法与YouTube数据API一起使用,因为服务帐户需要关联的YouTube频道,并且您无法将新的或现有的频道与链接 https://developers.google.com/youtube/v3/guides/的服务帐户moving_to_oauth dotnet中还有其他方法可以跳过用户同意并以编程方式进行身份验证,并以编程方式将视频上传到我的帐户吗?

So I found that ‘Service Accounts’ can be used for this kind of scenarios but again found that service account do not work with Youtube data API because Service Accounts require an associated YouTube channel, and you cannot associate new or existing channels with service accounts for the link https://developers.google.com/youtube/v3/guides/moving_to_oauth Is there any alternative way in dotnet to skip the user consent and get authenticated programmatically and do a programmatically upload of videos to my account

推荐答案

这是用户首次进行身份验证,他必须接受条款(允许您的应用访问其资源...).从那时起,该库将存储访问和刷新令牌.访问令牌的有效期为60分钟,过期后,库将使用刷新令牌来刷新访问令牌并获得有效的令牌.

It's only the first time a user authenticates that he will have to accept the terms (allowing your app to access his resources...). From that point, the library stores that access and refresh tokens. The access token is valid for 60 minutes, and when it expires the library uses the refresh token to refresh the access token and get a valid one.

如果您根本不想征得用户的同意,则应按照

If you don't want to have user consent at all, you should use the ServiceAccount flow as described in https://developers.google.com/api-client-library/dotnet/guide/aaa_oauth#service-account

这篇关于未经用户同意,使用youtube Data API V3将视频自动上传到我的帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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