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

Jyo*_*ngh 7 google-api youtube-api c#-4.0 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))
      {
        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();
    }
Run Code Online (Sandbox Code Playgroud)

但获得403回复

Error: Google.Apis.Requests.RequestError
Insufficient Permission [403]
Errors [
        Message[Insufficient Permission] Location[ - ] Reason[insufficientPermis
sions] Domain[global]
]
Run Code Online (Sandbox Code Playgroud)

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

Joe*_*Joe 0

该错误翻译为:

您尝试删除的视频无法删除。该请求可能未得到正确授权。

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

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