加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c#-4.0 – 如何使用youtube v3 api和C#从youtube中删除视频

发布时间:2020-12-15 07:52:50 所属栏目:百科 来源:网络整理
导读:好吧,我可以在Youtube上传视频,但我找不到从Youtube上删除视频/视频的方法或相关代码. 这是我试图删除youtube视频的代码. private async Task Run() { UserCredential credential; using (var stream = new FileStream("client_secret.json",FileMode.Open,F
好吧,我可以在Youtube上传视频,但我找不到从Youtube上删除视频/视频的方法或相关代码.

这是我试图删除youtube视频的代码.

private async Task Run()
    {
      UserCredential credential;
      using (var stream = new FileStream("client_secret.json",FileMode.Open,FileAccess.Read))
      {
        credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
            GoogleClientSecrets.Load(stream).Secrets,new[] { YouTubeService.Scope.Youtube },"user",CancellationToken.None
        );
      }
      var youtubeService = new YouTubeService(new BaseClientService.Initializer()
      {
        HttpClientInitializer = credential,ApplicationName = Assembly.GetExecutingAssembly().GetName().Name
      });

      var videosDeleteRequest = youtubeService.Videos.Delete("Video ID");
      await videosDeleteRequest.ExecuteAsync();
    }

但获得403回复

Error: Google.Apis.Requests.RequestError
Insufficient Permission [403]
Errors [
        Message[Insufficient Permission] Location[ - ] Reason[insufficientPermis
sions] Domain[global]
]

一点帮助或任何可能的解决方案将是非常值得注意的.

解决方法

该错误转换为:

The video that you are trying to delete cannot be deleted. The request
might not be properly authorized.

https://developers.google.com/youtube/v3/docs/videos/delete

您是否成功获得了拥有该视频的用户的令牌?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读