Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 4.0 如何使用youtube v3 api和C从youtube删除视频#_C# 4.0_Google Api_Youtube Api_Google Oauth_Google Api Dotnet Client - Fatal编程技术网

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

C# 4.0 如何使用youtube v3 api和C从youtube删除视频#,c#-4.0,google-api,youtube-api,google-oauth,google-api-dotnet-client,C# 4.0,Google Api,Youtube Api,Google Oauth,Google Api Dotnet Client,我可以在Youtube上上传视频,但我没有找到从Youtube上删除视频的方法或相关代码 这是我试图删除youtube视频的代码 private async Task Run() { UserCredential credential; using (var stream = new FileStream("client_secret.json", FileMode.Open, FileAccess.Read)) { credentia

我可以在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]
]

一点帮助或任何可能的解决方案都是非常值得的。

错误转化为:

无法删除您试图删除的视频。请求 可能未得到适当授权


您是否已成功获取拥有视频的用户的令牌?

您的身份验证看起来正确,这也是正确的范围您确定您使用的身份验证用户/频道具有该视频id吗?首先尝试创建视频列表以确保。我们可以使用相同的连接上载视频,但当我们尝试获取视频列表或删除视频时,此连接无法工作。它给了我们403的回复。谢谢@DaImTo的帮助。现在我们可以使用带有访问令牌的google delete API删除视频了。有什么问题吗?@jyotissingh在上面的代码中你是如何使用承载令牌的,我就是搞不懂?