简体   繁体   中英

"Could not load default credentials" google cloud secrets manager - use CLI authorized user

I would like to have my nodeJS application authenticate itself locally with my IAM credentials, however when I run the basic secrets manager function below:

// 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

I receive the error:

Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information. at GoogleAuth.getApplicationDefaultAsync

I can't seem to find any documentation on how to use my CLI login credentials locally, any ideas ?

(I don't want to use a JSON service account config)

Even if you're authenticated with the gcloud CLI you need to set the default application login . This is solved by running gcloud auth application-default login

Source: Could not load the default credentials? (Node.js Google Compute Engine tutorial)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM