Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从Github运行Google.api.YouTube.Samples.Upload项目时授权失败_C#_Google Api_Google Oauth_Youtube Data Api_Google Api Dotnet Client - Fatal编程技术网

C# 从Github运行Google.api.YouTube.Samples.Upload项目时授权失败

C# 从Github运行Google.api.YouTube.Samples.Upload项目时授权失败,c#,google-api,google-oauth,youtube-data-api,google-api-dotnet-client,C#,Google Api,Google Oauth,Youtube Data Api,Google Api Dotnet Client,我是youtube api的新手。我想有一个控制台程序时间表上传视频到youtube未经授权每次 我看到了很多帖子和视频,但没有看到完整的故事,我从Github下载了示例并尝试运行它。它失败了 我遵循指南 .创建OAuth客户端ID和应用程序类型选择其他 .从github下载代码 。单击浏览器中的“允许”,允许youtube api管理youtube帐户 哪一部分出了问题,我该如何解决?请帮忙 您收到的错误意味着您尚未对YouTube服务进行身份验证。您的凭据一定有问题,我看不到,因为您

我是youtube api的新手。我想有一个控制台程序时间表上传视频到youtube未经授权每次

我看到了很多帖子和视频,但没有看到完整的故事,我从Github下载了示例并尝试运行它。它失败了

我遵循指南

.创建OAuth客户端ID和应用程序类型选择其他

.从github下载代码

。单击浏览器中的“允许”,允许youtube api管理youtube帐户


哪一部分出了问题,我该如何解决?请帮忙

您收到的错误意味着您尚未对YouTube服务进行身份验证。您的凭据一定有问题,我看不到,因为您尚未发布所有代码

YouTube API不支持服务帐户。您需要至少对代码进行一次身份验证。这是通过web浏览器完成的,您使用的客户端库将在%appData%目录中存储“用户”的凭据

您正在学习的教程没有提到任何不需要身份验证的内容。这是身份验证的代码

UserCredential credential;
      using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read))
      {
        credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
            GoogleClientSecrets.Load(stream).Secrets,
            // This OAuth 2.0 access scope allows for full read/write access to the
            // authenticated user's account.
            new[] { YouTubeService.Scope.Youtube },
            "user",
            CancellationToken.None,
            new FileDataStore(this.GetType().ToString())
        );
      }

将来请发布您的代码,而不是代码的屏幕截图。请查看示例程序,并包括您提供的部分代码。我是新来的,所以我只能在帖子中发布两个链接。@Dalm,和你的完全一样,但错误是未经授权的。网络、代理、防火墙是否受到影响?