2014-10-01 132 views
1

我试图将不公开的视频上传到我的YouTube帐户,但仍然收到我无法解决的错误。目前,据我所知,YouTube Data Api 3目前不支持任何.Net。在我的两天搜索答案期间,我看到最成功的人使用过Google GData。将视频上传到YouTube,执行请求失败,(401)未授权

以下是我试图发布YouTube视频的GData。

Imports Microsoft.VisualBasic 
Imports System 
Imports System.IO 
Imports System.Reflection 
Imports System.Threading 
Imports System.Threading.Tasks 

Imports Google.GData.Client 
Imports Google.GData.Extensions 
Imports Google.GData.YouTube 
Imports Google.GData.Extensions.MediaRss 
Imports Google.YouTube 

Sub DirectUpload() 

     Dim APIkey As String = "MyKey" 
     Dim Path As String = "c://Users/Shaun/Desktop/TestVid/test.mp4" 
     Dim Title = "My Test Movie1" 

     Dim settings As New YouTubeRequestSettings("Uploader", APIkey) 
     settings.Timeout = 60 * 60 * 1000 
     Dim request As New YouTubeRequest(settings) 

     Dim service As New YouTubeService("Uploader", APIkey) 
     DirectCast(request.Service.RequestFactory, GDataRequestFactory).Timeout = 9999999 
     DirectCast(service.RequestFactory, GDataRequestFactory).KeepAlive = False 

     Dim newVideo As New Video() 

     newVideo.Title = Title 
     newVideo.Tags.Add(new MediaCategory("People & Blogs", YouTubeNameTable.CategorySchema)) 
     newVideo.Keywords = "Halls" 
     newVideo.Description = "Halls-" + Title 
     newVideo.YouTubeEntry.Private = true 
     'newVideo.Tags.Add(new MediaCategory("mydevtag, anotherdevtag", YouTubeNameTable.DeveloperTagSchema)) 
     newVideo.YouTubeEntry.MediaSource = new MediaFileSource(Path,"video/quicktime") 

     dim createdVideo As Video = request.Upload(newVideo) 
     'Success 

End Sub 

我收到以下错误信息:

Execution of request failed: https://uploads.gdata.youtube.com/feeds/api/users/default/uploads

The remote server returned an error: (401) Unauthorized.

我认为这必须是用户permitions为未经授权的。 我创建了一个产品和用户开发者密钥设置?:

enter image description here

回答

0
+0

我还没有看到一个工作.NET示例,今天尝试了一整天未知应用程序(https://www.google.com/settings/u/1/security/lesssecureapps)使用YouTube数据API 3.访问正如在问题中提到我已经回到YouTube数据API 2,因为我还有很多。 – Pomster 2014-10-01 14:12:06

+0

本页提供了完整的.net示例:https://developers.google.com/youtube/v3/docs/videos/insert ...您说:“YouTube数据API 3不支持任何.Net “但它确实,所以也许你以前没有见过这个!? – 2014-10-01 14:13:23

+0

今天我尝试了几次这个例子,凭证和YouTubeService都起作用。很可能我的一些C#到VB是不正确的,但即使在更新我的nuget包之后,也更多地丢失了dll。只要眼睛能看见就会发现错误。 – Pomster 2014-10-01 14:18:21

0

每一个谷歌帐户被阻止不明应用程序访问。
也许您已收到Google安全小组发送的有关未知活动的电子邮件。
需要登录并授予在谷歌帐户的安全设置

相关问题