.NET YouTube Google API上传凭证错误 [英] .NET YouTube Google APIs upload credential error
问题描述
我一直试图设置Google API来将视频上传到YouTube。
我已经进行了基本的设置了。我可以。
- 在VS2017中设置CLI项目
- 使用NuGet安装YouTube v3
- 完全按照此处中的内容复制YouTube示例代码
- 从API页面下载我的
client_secrets.json
(包括网页和安装版本,安装的版本就是我使用的) >
如果我删除 try
catch
这是我得到的详细错误
发生System.AggregateException
HResult = 0x80131500
Message =发生一个或多个错误。
Source = mscorlib
StackTrace:System.Threading.Tasks.Task.ThrowIfExceptional上的
(布尔includeTaskCanceledExceptions)$ System.Threading.Tasks.Task.Wait上的
(Int32 millisecondsTimeout,CancellationToken在C:\ Users \ CHALICE_ITDept\\中的Google.Apis.YouTube.Samples.UploadVideo.Main(String [] args)处的System.Threading.Tasks.Task.Wait()
处为
) \\ Documents \ Visual Studio 2017\Projects\ConsoleApp1\ConsoleApp1\Program.cs:第31行
内部异常1:
TokenResponseException:错误:invalid_client,说明: 未经授权,Uri:
如果我设置了与web项目相同的代码,使用我的 web
键,页面只是挂起并且什么也不做。
我已经能够使用我的 web
键与JavaScript示例代码,它工作正常。
我正在处理的项目的目标是让我的用户(来自密码) d受保护的页面)将他们的视频直接上传到我的YouTube帐户。然后我将视频ID存储到我的网页上。我想在没有用户登录Google帐户的情况下这样做。所以我将存储我自己的访问/认证/刷新/等令牌....但我还没有得到那么多。
我无法通过 credential =等待GoogleWebAuthorizationBroker.AuthorizeAsync()
点,我不知道为什么。
如果我尝试使用 web
键,URL重定向总是失败,因为VS使用的端口是随机的,所以我无法将其添加到'授权重定向URI'中。
所以,你好随意。我生成了一套全新的O'Auth API密钥,现在它可以工作......
I have been attempting to setup the Google APIs to upload a video to YouTube.
I have gone to as basic a setup I can.
- Setup a CLI project in VS2017
- Use NuGet to install YouTube v3
- Copy the YouTube Sample code exactly as it is from here
- download my
client_secrets.json
from the API page (both web and installed versions, the installed version is what I am using)
If I remove the try
catch
this is the detailed error I get
System.AggregateException occurred
HResult=0x80131500
Message=One or more errors occurred.
Source=mscorlib
StackTrace:
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at Google.Apis.YouTube.Samples.UploadVideo.Main(String[] args) in C:\Users\CHALICE_ITDept\Documents\Visual Studio 2017\Projects\ConsoleApp1\ConsoleApp1\Program.cs:line 31
Inner Exception 1:
TokenResponseException: Error:"invalid_client", Description:"Unauthorized", Uri:""
If I set up the same code as a web project, and use my web
keys, the page just hangs and does nothing.
I have however been able to use my web
keys with the Javascript sample code, and it works fine.
My goal with the project I am working on is to have my user (from a password protected page) upload their video directly to my YouTube Account. I then store the video ID to re-embed back on my webpage. I want to do this without the user having to sign into a google account. So I will be storing my own access/authentication/refresh/etc token.... but I havent got that far yet.
I can't get passed the credential = await GoogleWebAuthorizationBroker.AuthorizeAsync()
point, and I don't know why.
If I try using the web
keys, the URL redirect will always fail because the port the VS uses is randomized so I can't add it to the 'Authorized redirect URIs'
So, hello random. I generated a whole new set of O'Auth API keys and now it works.....
这篇关于.NET YouTube Google API上传凭证错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!