我正在使用 YouTube api 尝试使用可恢复上传器上传视频。我真的宁愿不必直接向用户询问他们的凭据。
我能够使用 AuthSub 并获得会话令牌。问题是我似乎无法将它与可恢复上传器一起使用。这是可能的还是完全分开的?我看到 GDataCredentials 可以获取客户端令牌。这是什么?我使用返回的会话令牌 Error = {“远程服务器返回错误:(401) 未授权。”}
这是我的代码
Video newVideo;
var mResumableUploader = new ResumableUploader(10485760);
mResumableUploader.AsyncOperationCompleted += mResumableUploader_AsyncOperationCompleted;
mResumableUploader.AsyncOperationProgress += mResumableUploader_AsyncOperationProgress;
var youTubeAuthenticator = new ClientLoginAuthenticator(AppName, ServiceNames.YouTube, new GDataCredentials(YouTubeToken));
youTubeAuthenticator.DeveloperKey = DevKey;
newVideo = new Video();
newVideo.Title = "video";
newVideo.Tags.Add(new MediaCategory("Entertainment", YouTubeNameTable.CategorySchema));
newVideo.Keywords = "video";
newVideo.Description = "video";
newVideo.YouTubeEntry.Private = false;
newVideo.YouTubeEntry.MediaSource = new MediaFileSource(FilePath, "video/mp4");
var link = new AtomLink("http://uploads.gdata.youtube.com/resumable/feeds/api/users/default/uploads");
link.Rel = ResumableUploader.CreateMediaRelation;
newVideo.YouTubeEntry.Links.Add(link);
mResumableUploader.InsertAsync(youTubeAuthenticator, newVideo.YouTubeEntry, "inserter");