2014-10-01 67 views
0

过去两天,我一直在尝试从我的网站上传视频到YouTube。 VB没有文档,也没有太多的.Net工作例子。将视频上传到youTube,第1步YouTube Data API 3获取UserCredential?

我正在寻找以任何方式将视频上传到YouTube。我尝试过YouTube Data API 3和YouTube Data API 2,但没有成功。

继YouTube的API我试图让我的UserCredentials https://developers.google.com/youtube/v3/code_samples/dotnet#upload_a_video

我创建了一个OAuth键值和谷歌的控制台上的公共API密钥。 https://console.developers.google.com/project

UserCredential credential; 
using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read)) 
{ 
    credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
    GoogleClientSecrets.Load(stream).Secrets, 
    // This OAuth 2.0 access scope allows for full read/write access to the 
    // authenticated user's account. 
    new[] { YouTubeService.Scope.Youtube }, 
    "user", 
    CancellationToken.None, 
    new FileDataStore(this.GetType().ToString()) 
); 
} 

如果有人得到这上面的部分工作或知道一个地方,我可以看到如何得到它的工作将非常感激。

我在YouTube数据API 3的尝试我必须使用VB,但会接受C#中的答案,因为我可以将其转换,任何有效的UserCredentials示例都将是一个可接受的答案。

两个问题的第一个是我需要这个在VB中。 我在()下面有一条蓝色的线。

Using stream = New FileStream("client_secrets.json", FileMode.Open, FileAccess.Read) 
    credential = GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.Load(stream).Secrets, New() {YouTubeService.Scope.YoutubeReadonly}, "user", CancellationToken.None, New FileDataStore(Me.[GetType]().ToString())) 
End Using 

第二个问题是我不知道应该进入“的client_secrets.json”

我在YouTube数据API 2尝试: Upload video to YouTube, Execution of request failed, (401) Unauthorized

+0

我想我已经得到了的client_secrets.json。 – Pomster 2014-10-01 15:39:57

回答