Youtube注释API抛出“权限不足:请求的身份验证范围不足”错误

时间:2019-05-14 23:05:32

标签: youtube youtube-api youtube-data-api youtube-analytics-api

我正在尝试获取Youtube注释,但它引发了此异常-

{“ Google.Apis.Requests.RequestError \ r \ n权限不足:请求的身份验证范围不足。[403] \ r \ nErrors [\ r \ n \ tMessage [权限不足:请求的身份验证范围不足。]位置[-]原因[insufficientPermissions]域[全局] \ r \ n] \ r \ n“}

凭据源代码-

UserCredential credsDataApi = GoogleWebAuthorizationBroker.AuthorizeAsync(
                GoogleClientSecrets.Load(stream).Secrets,
                new[] { YouTubeService.Scope.YoutubeForceSsl, YouTubeService.Scope.Youtubepartner, YouTubeAnalyticsService.Scope.YtAnalyticsReadonly, YouTubeAnalyticsService.Scope.YtAnalyticsMonetaryReadonly, YouTubeAnalyticsService.Scope.Youtube, "https://www.googleapis.com/auth/plus.login" },

                "user",
                CancellationToken.None,
                new FileDataStore(Directory.GetCurrentDirectory() + "\\MetadataAccessToken\\" + channelinfo.DataAPIFileDataStore, true)
                ).Result; 

这是引发异常的行-

UserCredential credsDataApi = YouTubeHelper.GetUserCredentialForDataAPI(channelinfo);
            var youtubeServiceComments = new YouTubeService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credsDataApi,
                ApplicationName = channelinfo.DataAPIFileDataStore
            });

var searchCommentThreadlistRequest = youtubeServiceComments.CommentThreads.List(“ snippet”);  var searchCommentThreadlistResponse = searchCommentThreadlistRequest.ExecuteAsync(); 如果( searchCommentThreadlistResponse.Result.Items.Count > 0){ }

能请你帮忙吗?

1 个答案:

答案 0 :(得分:0)

我可以在此范围内对其进行修复-enter image description here