我正在将视频从本地上传到youtube。
在本地服务器中,它运行正常,验证窗口正在打开。但是在上传视频时,我正在运行以下代码并收到此错误。
2017-04-22 02:57:34.275 -05:00 [Information] C:\Backups\inetpub\YouTube\client_secrets.json
2017-04-22 02:57:34.479 -05:00 [Information] ==========Failed to launch browser with "https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&response_type=code&client_id=357849494845-pg20dbmdnhoi5gk8go2bakbs9q8635q8.apps.googleusercontent.com&redirect_uri=http:%2F%2Flocalhost:53639%2Fauthorize%2F&scope=https:%2F%2Fwww.googleapis.com%2Fauth%2Fyoutube.upload" for authorization. See inner exception for details.=============
2017-04-22 02:57:34.481 -05:00 [Information] ========== at Google.Apis.Auth.OAuth2.LocalServerCodeReceiver.<ReceiveCodeAsync>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Google.Apis.Auth.OAuth2.AuthorizationCodeInstalledApp.<AuthorizeAsync>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.<AuthorizeAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.<AuthorizeAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at YoutubeApiDemo.classes.UploadVideo.<Run>d__3.MoveNext() in C:\Users\GLB-008PC\Desktop\New folder\YoutubeApiDemo\src\YoutubeApiDemo\classes\UploadVideo.cs:line 45=============
2017-04-22 02:57:34.487 -05:00 [Debug] Executed action method "YoutubeApiDemo.Controllers.HomeController.UploadVideo (YoutubeApiDemo)", returned result "Microsoft.AspNetCore.Mvc.ContentResult".
2017-04-22 02:57:34.488 -05:00 [Information] Executing ContentResult with HTTP Response ContentType of "text/plain; charset=utf-8"
2017-04-22 02:57:34.489 -05:00 [Information] Executed action "YoutubeApiDemo.Controllers.HomeController.UploadVideo (YoutubeApiDemo)" in 224.0549ms
2017-04-22 02:57:34.489 -05:00 [Information] Request finished in 226.4115ms 200 text/plain; charset=utf-8
2017-04-22 02:57:34.489 -05:00 [Debug] Connection id ""0HL49AKRM6GUK"" completed keep alive response.
我执行此任务的代码是:
using (var stream = new FileStream(client_secret_path, FileMode.Open, FileAccess.Read))
{
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
new[] { YouTubeService.Scope.Youtube, YouTubeService.Scope.YoutubeUpload },
username,
CancellationToken.None,
new FileDataStore("YouTube.Auth.Store")).Result;
}