小编Dav*_*vid的帖子

Google Oauth错误:应设置至少一个客户端机密(已安装或Web)

我正在使用Google的Oauth 2.0通过我们的服务器将视频上传到Youtube.我的客户ID是"服务帐户".我下载了json密钥并将其添加到我的解决方案中.

这是相关代码:

 private async Task Run(string filePath)
        {
            UserCredential credential;
            var keyUrl = System.Web.HttpContext.Current.Server.MapPath("~/content/oauth_key.json");
            using (var stream = new FileStream(keyUrl, FileMode.Open, FileAccess.Read))
            {
                credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
                    GoogleClientSecrets.Load(stream).Secrets,
                    // This OAuth 2.0 access scope allows an application to upload files to the
                    // authenticated user's YouTube channel, but doesn't allow other types of access.
                    new[] { YouTubeService.Scope.YoutubeUpload },
                    "user",
                    CancellationToken.None
                );
            }

            var youtubeService = new YouTubeService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = Assembly.GetExecutingAssembly().GetName().Name
            });
Run Code Online (Sandbox Code Playgroud)

当我运行它时,我收到此错误:应设置至少一个客户端机密(已安装或Web).

但是,在我的json中没有"客户秘密":

{ …
Run Code Online (Sandbox Code Playgroud)

c# oauth-2.0 google-oauth

15
推荐指数
3
解决办法
9689
查看次数

标签 统计

c# ×1

google-oauth ×1

oauth-2.0 ×1