How to remove videos from youtube using youtube v3 api and C #

Well, I can upload videos to Youtube, but I have not found a way or corresponding code to delete videos / videos from Youtube.

Here is my code that I tried to remove youtube video.

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(); } 

But getting a response 403

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

A little help or any possible solution will be very noticeable.

+7
youtube-api google-oauth google-api google-api-dotnet-client
source share
1 answer

The error translates to:

The video you are trying to delete cannot be deleted. The request may not be properly resolved.

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

Have you successfully purchased the token of the user who owns the video?

0
source share

All Articles