我想设置推送通知手表,但收到错误响应。我需要什么授权?
Request:
// Google API
$client = getClient();
// POST request
$ch = curl_init('https://www.googleapis.com/gmail/v1/users/me/watch');
curl_setopt_array($ch, array(
CURLOPT_POST => TRUE,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer ' . $client->getAccessToken()['access_token'],
'Content-Type: application/json'
),
CURLOPT_POSTFIELDS => json_encode(array(
'topicName' => 'projects/xxxx/topics/xxxx',
'labelIds' => ["INBOX"]
))
));
回复:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "forbidden",
"message": "Error sending test message to Cloud PubSub projects/xxxx/topics/xxxx : User not authorized to perform this action."
}
],
"code": 403,
"message": "Error sending test message to Cloud PubSub projects/xxxx/topics/xxxx : User not authorized to perform this action."
}
}
更多细节:
- 使用的范围是
GMAIL_READONLY
.
- 订阅和主题存在,并且它们是在同一控制台中创建的。
- 我尝试从控制台发布一条新消息,它成功了。
从页面:https://developers.google.com/gmail/api/guides/push#grant_publish_rights_on_your_topic https://developers.google.com/gmail/api/guides/push#grant_publish_rights_on_your_topic
Cloud Pub/Sub 要求您授予 Gmail 发布权限
您的主题的通知。
为此,您需要授予发布权限
服务帐号:[电子邮件受保护] /cdn-cgi/l/email-protection。你可以做
这使用 Cloud Pub/Sub 开发者控制台权限界面
遵循资源级访问控制指令。
(强调已添加)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)