Gmail API Watch() 不起作用

Fur*_* S. 3 google-api-php-client gmail-api

我正在关注https://developers.google.com/gmail/api/guides/push 上给出的 Gmail API 推送通知指南。但是,当我尝试从 API 资源管理器创建新手表时,它给出了以下响应:

{
 "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/*"
 }
Run Code Online (Sandbox Code Playgroud)

}

我的要求如下:

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"
}
Run Code Online (Sandbox Code Playgroud)

似乎在 Google API 端进行了错误的验证检查。还有其他人面临这个问题吗?

Eri*_*c D 6

您不能使用 API 资源管理器进行该调用,您需要直接进行(使用您的客户端,而不是 API 资源管理器)才能按照指南进行正确验证:https : //developers.google.com/gmail/ api/guides/push#gmail_watch

如果未完成该检查,理论上您可以使用 API 资源管理器向任何其他开发人员的任意 Cloud Pub/Sub 主题发送通知。