【发布时间】:2019-06-12 07:40:35
【问题描述】:
我有一个 GCD 帐户,在该帐户中我在后者中创建了一个项目和数据存储。我下载了该项目的服务帐户密钥并存储在我的本地 PC 中。
现在,我的 PC 上运行了一个简单的节点应用程序。这个节点应用程序有一个简单的查询来从上面创建的谷歌数据存储中获取数据。我只需要知道我应该如何在我的节点应用程序中配置服务帐户密钥以获取对数据存储区和相应实体的访问权限,因为当我尝试访问时出现这样的错误 - “权限缺失或不足。”
节点应用查询 -
// Adding a Sample Entity
async function quickStart() {
// Your Google Cloud Platform project ID
const projectId = 'XXX';
// Creates a client
const datastore = new Datastore({
projectId: projectId,
});
// The kind for the new entity
const kind = 'xxx';
// The name/ID for the new entity
const name = xxxx;
// The Cloud Datastore key for the new entity
const sampleKey = datastore.key([kind, name]);
const [entity] = await datastore.get(sampleKey);
console.log(entity);
}
quickStart().catch(console.error);
【问题讨论】:
标签: node.js authentication google-cloud-platform google-cloud-datastore