gpt4 book ai didi

php - 错误 403 : Error sending test message to Cloud PubSub: User not authorized to perform this action

转载 作者:行者123 更新时间:2023-12-04 21:08:44 24 4
gpt4 key购买 nike

我想设置推送通知 watch ,但收到错误响应。我需要什么授权?

要求:

// 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

    Cloud Pub/Sub requires that you grant Gmail privileges to publish notifications to your topic.

    To do this, you need to grant publish privileges to serviceAccount:gmail-api-push@system.gserviceaccount.com. You can do this using the Cloud Pub/Sub Developer Console permissions interface following the resource-level access control instructions.



    (强调)

    关于php - 错误 403 : Error sending test message to Cloud PubSub: User not authorized to perform this action,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46133481/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com