1

我正在通过 pub/sub 将来自 gmail 的通知发送到网络服务器,

我已经阅读了他们提到的启用范围的文档

https://cloud.google.com/pubsub/configure

我通过代码指定以下范围

https://www.googleapis.com/auth/cloud-platform,
https://www.googleapis.com/auth/pubsub

即使在为特定用户调用 watch() 之后指定了这些范围之后,它也给了我

Google::Apis::ClientError: forbidden: Error sending test message to Cloud PubSub projects/project-id/topics/topic-name : User not authorized to perform this action.

那么我需要从谷歌控制台启用这些范围吗?如果是,那么你能告诉我们这样做的方向吗?

4

1 回答 1

3

范围在这里不相关。Gmail 系统始终使用此服务帐户“gmail-api-push@system.gserviceaccount.com”。您需要做的是授予此服务帐户在您的主题上发布消息的权限。

另请参阅: https ://developers.google.com/gmail/api/guides/push#grant_publish_rights_on_your_topic

于 2016-02-20T07:46:44.560 回答