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

前端之家收集整理的这篇文章主要介绍了c#-4.0 – 如何使用youtube v3 api和C#从youtube中删除视频前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
好吧,我可以在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

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

原文链接:https://www.f2er.com/csharp/99795.html

猜你在找的C#相关文章