我尝试使用此处的指南获取通知。 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/