我正在尝试将不公开的视频上传到我的YouTube帐户,我仍然会收到无法解决的错误。据我所知,YouTube Data Api 3目前不支持任何.Net,在我的两天搜索答案中,我看到最成功的人使用了Google GData。
以下是我尝试发布YouTube视频的尝试。
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
我收到以下错误消息:
执行请求失败: https://uploads.gdata.youtube.com/feeds/api/users/default/uploads
远程服务器返回错误:(401)未经授权。
我认为这必须是用户权限,因为它是未经授权的。 我创建了一个产品和开发者密钥提供的用户?:
答案 0 :(得分:0)
答案 1 :(得分:0)
每个Google帐户都会因未知应用程序访问而被阻止 也许你收到了谷歌安全团队关于未知活动的电子邮件 需要在Google帐户安全设置(https://www.google.com/settings/u/1/security/lesssecureapps)
上登录并授予对未知应用程序的访问权限