但是,当我运行下面的基本nodeJS函数时,我希望让我的IAM应用程序在本地使用IAM凭据进行身份验证:
// config/secret_manager.js
const { SecretManagerServiceClient } = require('@google-cloud/secret-manager')
const client = new SecretManagerServiceClient()
async function getSecret(name) {
const [version] = await client.accessSecretVersion({ name })
const secretValue = JSON.parse(version.payload.data.toString())
return secretValue
}
module.exports = getSecret我收到错误:
无法加载默认凭据。浏览到https://cloud.google.com/docs/authentication/getting-started以获得更多信息。在GoogleAuth.getApplicationDefaultAsync
我似乎找不到任何关于如何在本地使用CLI登录凭据的文档,any ideas
(我不想使用JSON服务帐户配置)
发布于 2021-05-16 18:07:03
即使您是使用gcloud CLI进行身份验证,也需要设置默认的应用程序登录名。这是通过运行gcloud auth application-default login来解决的
来源:Could not load the default credentials? (Node.js Google Compute Engine tutorial)
https://stackoverflow.com/questions/67560015
复制相似问题