node.js - “无法加载默认凭据”谷歌云机密管理器 - 使用 CLI 授权用户
问题描述
我想让我的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 服务帐户配置)
解决方案
即使您已通过身份验证,gcloud
CLI
您也需要设置默认应用程序登录。这可以通过运行解决gcloud auth application-default login
推荐阅读
- c++ - 超过时限
- java - 我正在尝试使用不同类中的方法,但它会产生错误
- unix - Unix将所有文件从主目录移动到另一个文件夹
- python - 气流:ExternalTaskSensor 无法按预期工作。不同的任务计划
- node.js - 挂钩 assert.* 函数
- rust - 产生数量合理的 Tokio 任务
- flutter - Flutter GeoLocator PermissionRequestInProgressException
- security - 如何使用实例给出的相同 access_token 在画布 lms 中保护我的 lti 工具?
- c# - Unity 中的 Resharper 和 linting C#
- c++ - C++ 函数模板:无法匹配最佳函数