0

我想让我的nodeJS应用程序使用我的凭据在本地进行身份IAM验证,但是当我运行以下基本secrets manager功能时:

// 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本地使用我的登录凭据的文档,有什么想法吗?

(我不想使用 JSON 服务帐户配置)

4

1 回答 1

0

即使您已通过身份验证,gcloud CLI 您也需要设置默认应用程序登录。这可以通过运行解决gcloud auth application-default login

来源:无法加载默认凭据?(Node.js 谷歌计算引擎教程)

于 2021-05-16T18:07:03.680 回答