Google PubSub - serviceAccount:gmail-api-push@system.gserviceaccount.com 不存在

Google PubSub - serviceAccount:gmail-api-push@system.gserviceaccount.com doesn't exist

我正在尝试使用 Google 的 Pub/Sub 订阅 Gmail 以获取邮件通知,并且我已经阅读了 Google 提供的文档和教程。有一次,the docs 声明我需要发布对我的 PubSub 主题的正确权限:

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.

我的理解是 publish 权限等同于 pubsub.topics.publish 或者只是 "PubSub Publisher"。但是 serviceAccount:gmail-api-push@system.gserviceaccount.com 呢?我无法在任何地方找到该服务帐户,并且由于字符限制,控制台不允许我创建它。是否有其他方式获取此帐户?

权限由 GCP Console Pub/Sub 主题部分中的 Pub/Sub 主题设置。

  • 转到 Google 云控制台。
  • 从 Hamburget 菜单,转到大数据 -> Pub/Sub -> 主题。 此位置的快捷方式:https://console.cloud.google.com/projectselector2/cloudpubsub/topicList

  • 单击主题的复选框。

  • 控制台右侧,select"SHOW INFO PANEL".
  • 点击添加成员
  • 输入服务帐户和select所需的角色。通常 Pub/Sub 出版商。

您不需要创建 gmail 服务帐户,它已经存在。您关于“授予发布权限”与“Pub/Sub 发布者”相同的说法是正确的。

在主题权限界面下,我会在'新成员'字段中传入服务帐户gmail-api-push@system.gserviceaccount.com(注意:去掉前面的“serviceAccount:”部分),select “Pub/Sub Publisher” 作为角色。

我猜您找不到服务帐户是因为您正在查找 serviceAccount:gmail-api-push@system.gserviceaccount.com