YouTube API可恢复上传器会话令牌

时间:2013-06-12 01:10:11

标签: wpf authentication upload youtube-api

我正在使用YouTube API尝试使用可恢复的上传器上传视频。我真的不想直接询问用户他们的凭据。

我可以使用AuthSub并获取会话令牌。问题是我似乎无法使用可恢复的上传器。这可能还是完全分开?我看到GDataCredentials可以使用客户端令牌。这是什么?我使用会话令牌我回来错误= {“远程服务器返回错误:(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");

1 个答案:

答案 0 :(得分:0)

ClientLogin is problematic,很快就会弃用。请使用OAuth2,您将不会遇到任何问题。