Gmail API Watch() not working

匿名 (未验证) 提交于 2019-12-03 01:03:01

问题:

I am following Gmail API Push notifications guide given at https://developers.google.com/gmail/api/guides/push. However, when I try to create a new watch from API explorer, it gives following response:

{  "error": {   "errors": [    {     "domain": "global",     "reason": "invalidArgument",     "message": "Invalid topicName does not match projects/google.com:apisexplorerconsole/topics/*"    }   ],   "code": 400,   "message": "Invalid topicName does not match projects/google.com:apisexplorerconsole/topics/*"  } 

}

My request seems as follows:

POST https://www.googleapis.com/gmail/v1/users/myemailaddress/watch?key={YOUR_API_KEY} {  "labelIds": [   "INBOX"  ],  "topicName": "projects/my-project-name/topics/my-topic-name" } 

Seems like faulty validation check at Google API end. Anyone else facing this problem?

回答1:

You can't use APIs explorer to make that call, you need to make it directly (using your client, not APIs explorer) for it to be correctly verified as per the guide: https://developers.google.com/gmail/api/guides/push#gmail_watch

If that check were not done, you could in theory use APIs explorer to send notifications to any random other developer's Cloud Pub/Sub topic.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!