作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
这段代码被截断了:
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,//read from client secret.json file
Scopes,
"user",
CancellationToken.None).Result;
// Create Gmail API service.
var service = new GmailService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = ApplicationName,
});
UsersResource.LabelsResource.ListRequest request = service.Users.Labels.List("me");
WatchRequest body = new WatchRequest()
{
TopicName = "projects/push-notifications-ver3/topics/mytopic",
LabelIds = new[] {"INBOX"}
string userId = "me";
UsersResource.WatchRequest watchRequest = service.Users.Watch(body, userId);
WatchResponse test = watchRequest.Execute();
获取错误:向 Cloud PubSub projects/push-notifications-ver3/topics/mytopic 发送测试消息时出错:用户无权执行此操作。 [403]
主题是通过订阅创建的,权限已授予当前用户作为主题所有者有什么建议为什么用户未被授权?
最佳答案
您是否为给定用户完成了 OAuth 流程?另外,您是否将 AuthorizeAsync() 方法中的“用户”一词替换为经过身份验证的用户?如果是,则尝试使用新的客户端 secret 文件执行此操作,并检查 PubSub Scope 是否存在于变量范围内。
我遇到了类似的问题,结果证明是这些问题之一。也可能对您有用。
关于c# - GmailService create Watch() 获取用户未授权错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34046598/
这段代码被截断了: credential = GoogleWebAuthorizationBroker.AuthorizeAsync( GoogleClientSe
目标:生成包含正文内容和附件的草稿电子邮件,并将其放入我当前用户的 GMail 帐户。 环境:ASP.NET Core 3.1 我已经在我的网络应用程序中使用了 Google 身份验证,并且成功地请求
我是一名优秀的程序员,十分优秀!