Youtube api v3评论 - 权限不足[403] c#

时间:2017-09-27 17:50:50

标签: c# .net youtube youtube-data-api

我正在尝试为我的程序中的视频添加评论,但是我收到以下错误:

Insufficient Permission [403]

错误[         消息[权限不足]位置[ - ]原因[insufficientPermissions]域[global] ]

要登录,我有以下代码:

        UserCredential credential;
        using (var stream = new FileStream(credentialsFile.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.YoutubeForceSsl },
                "user",
                CancellationToken.None,
                new FileDataStore(this.GetType().ToString())
            );
        }

        var youtubeService = new YouTubeService(new BaseClientService.Initializer()
        {
            HttpClientInitializer = credential,
            ApplicationName = this.GetType().ToString()
        });

要插入代码我有这段代码:

CommentSnippet snippet = new CommentSnippet();
        snippet.TextOriginal = text;
        Comment comment = new Comment();
        comment.Snippet = snippet;
        CommentThreadSnippet threadSnippet = new CommentThreadSnippet();
        threadSnippet.VideoId = videoID;
        threadSnippet.TopLevelComment = comment;
        CommentThread commentThread = new CommentThread();
        commentThread.Snippet = threadSnippet;
        CommentThreadsResource.InsertRequest insertComment = youtubeService.CommentThreads.Insert(commentThread, "snippet");
        insertComment.Execute();

我在其他帖子中读到我应该使用范围“YoutubeForceSsl”,我还创建了一个新的OAuth凭证文件,但它仍然不起作用...

感谢您的回复!

0 个答案:

没有答案