【发布时间】:2014-09-11 15:04:03
【问题描述】:
我的应用程序中集成了 youtube api v2。 我有 API 密钥,我想集成 Youtube API v3,但我收到错误 401(响应状态码不表示成功) 在
Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task) at Google.Apis.Upload.ResumableUpload`1.d__0.MoveNext() in c:\代码\google.com\google-api-dotnet-client\default\Tools\Google.Apis.Release\bin\Debug\output\default\Src\GoogleApis\Apis[媒体]\Upload\ResumableUpload.cs:377行
这是相关代码:
var youtubeService = new YouTubeService(new BaseClientService.Initializer()
{
ApiKey = "myapikey",
ApplicationName = ConfigurationManager.AppSettings["YoutubeApplicationName"].ToString(),
});
var video = new Video();
video.Snippet = new VideoSnippet();
video.Snippet.Title = "Default Video Title";
video.Snippet.Description = "Default Video Description";
video.Snippet.Tags = new string[] { "tag1", "tag2" };
video.Snippet.CategoryId = "22"; // See https://developers.google.com/youtube/v3/docs/videoCategories/list
video.Status = new VideoStatus();
video.Status.PrivacyStatus = "unlisted"; // or "private" or "public"
var filePath = @"REPLACE_ME.mp4"; // Replace with path to actual movie file.
using (streamVideo)
{
var videosInsertRequest = youtubeService.Videos.Insert(video, "snippet,status", streamVideo, "video/*");
videosInsertRequest.ProgressChanged += videosInsertRequest_ProgressChanged;
videosInsertRequest.ResponseReceived += videosInsertRequest_ResponseReceived;
await videosInsertRequest.UploadAsync();
}
【问题讨论】:
标签: c# youtube youtube-api