.net - 500 错误。内部 [后端错误] Google Api Push #gmail_watch

标签 .net gmail-api

我尝试使用此处的指南获取通知。 https://developers.google.com/gmail/api/guides/push#gmail_watch

Gmailservice(service) 可以获取标签、收件箱等api功能。

这里是代码。

        var service = new GmailService(new BaseClientService.Initializer()
    {
        HttpClientInitializer = credential,
        ApplicationName = ApplicationName,
    });
    IList<string> label = new List<string>();
    label.Add("INBOX");
    WatchRequest request2 = new WatchRequest
    {
        LabelIds = label,
        LabelFilterAction = "include",
        TopicName = "projects/******/topics/****TestTopic"
    };
    var x= service.Users.Watch(request2, "me").Execute();

watch 抛出此异常

Google.Apis.Requests.RequestError
Backend Error [500]
Errors [
    Message[Backend Error] Location[ - ] Reason[backendError] Domain[global]
]

最佳答案

好的,我的解决了。 是的,我同意,来自 gmail API 的错误消息有些晦涩,但这是我修复它的方法。

显然,我忘记向 gmail 授予 Push 权限。 这样做去here并执行以下操作:

  • 选择您的项目。
  • 从右侧的选项卡中,向 gmail-api-push@system.gserviceaccount.com 授予推送权限。

祝你好运!

关于.net - 500 错误。内部 [后端错误] Google Api Push #gmail_watch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47701134/

相关文章:

c# - linq2sql图片保存问题

c# - EF 不在数据库级别执行 where 子句

.net - IdentityServer 4 还是 OpenIddict?

.net - 是否安装了 .NET 版本的 DSC 资源?

php - 跟踪在 gMail 中打开的电子邮件

python-3.x - 使用 Google API 发送邮件时出错 - "' raw' RFC822 有效负载消息字符串或通过/upload/* URL 上传消息需要”

java - Gmail API 配置问题(Java 中)

.net - 是否可以通过反射设置私有(private)属性?

python - 使用 Gmail API 在 html 中检索电子邮件/消息正文

python - 将电子邮件从一个 Gmail 邮箱导入到另一个邮箱