【发布时间】:2019-09-25 15:25:47
【问题描述】:
我创建了一个 gcloud 计算实例,我想在同一个项目中使用 storage.objects.get 和 firebasedatabase.instances.update 范围执行操作。
每个实例都是使用 Compute Engine 默认服务帐号 numbers-compute@developer.gserviceaccount.com 创建的,该帐号在项目中具有 Editor 角色。因此,我假设实例在使用初始化时将具有所需的权限
admin.initializeApp({
credential: admin.credential.applicationDefault()
});
然而,请求一个 firestore 实例会导致错误 Request had insufficient authentication scopes。
现在我注意到,如果我 gcloud compute instances describe my-instance 结果同时提到了电子邮件和 serviceAccounts 的范围:
"serviceAccounts": [
{
"email": "numbers-compute@developer.gserviceaccount.com",
"scopes": [
"https://www.googleapis.com/auth/devstorage.read_only",
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring.write",
"https://www.googleapis.com/auth/pubsub",
"https://www.googleapis.com/auth/service.management.readonly",
"https://www.googleapis.com/auth/servicecontrol",
"https://www.googleapis.com/auth/trace.append"
]
}
]
服务帐户电子邮件和预定义范围之间的关系是什么?实例是否未应用服务帐户的所有范围?
即使我想调整我的范围,我也需要一些帮助来将storage.objects.get 和firebasedatabase.instances.update iam 定义转换为https://www.googleapis.com/auth/scope 格式。 (https://www.googleapis.com/auth/firebasedatabase.instances.update 不存在)
【问题讨论】:
标签: google-compute-engine google-api-nodejs-client