gpt4 book ai didi

youtube - Youtube API C#错误,无法发表评论?我还应该怎么办

转载 作者:行者123 更新时间:2023-12-03 06:05:33 25 4
gpt4 key购买 nike

async Task AddVideoCommentAsync(string commentToAdd, string videoID, YouTubeService youtubeService)
{
CommentSnippet commentSnippet = new CommentSnippet();
commentSnippet.TextOriginal = commentToAdd;

Comment topLevelComment = new Comment();
topLevelComment.Snippet = commentSnippet;

CommentThreadSnippet commentThreadSnippet = new CommentThreadSnippet();
commentThreadSnippet.ChannelId = "UCsK0terzCGmIPAeGmW-i-VA";
commentThreadSnippet.VideoId = videoID;
commentThreadSnippet.TopLevelComment = topLevelComment;

CommentThread commentThread = new CommentThread();
commentThread.Snippet = commentThreadSnippet;


CommentThreadsResource.InsertRequest insertComment = youtubeService.CommentThreads.Insert(commentThread, "snippet");

await insertComment.ExecuteAsync();
}
这是我在自己选择的视频上添加评论的代码。
怎么了我从这里的另一个问题获得了此代码,并对其进行了一些更改,但是:
Error: Google.Apis.Requests.RequestError
Request had insufficient authentication scopes. [403]
Errors [
Message[Insufficient Permission] Location[ - ] Reason[insufficientPermissions] Domain[global]
]```

最佳答案

根据 CommentThreads.insert API端点的官方文档,调用它的先决条件如下:

Authorization

This request requires authorization with at least one of the following scopes (read more about authentication and authorization).

Scope
https://www.googleapis.com/auth/youtube.force-ssl


因此,您的 youtubeService应该已经通过在OAuth 2.0身份验证/授权流程中获得的凭据进行了初始化,并且这些凭据应该已附加在上述范围内。

关于youtube - Youtube API C#错误,无法发表评论?我还应该怎么办,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64446211/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com