问题
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'
回答1:
So, hello random. I generated a whole new set of O'Auth API keys and now it works.....
来源:https://stackoverflow.com/questions/49364545/net-youtube-google-apis-upload-credential-error