I can't figure out why I keep getting the error: Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.
firebase login
from my command line returns that I am already logged in and
I have configured [email protected]
to be a Secret Manager Secret Accessor in the GCP IAM admin dashboard within the same project.
Here's the code I'm using:
const { SecretManagerServiceClient } = require("@google-cloud/secret-manager");
const client = new SecretManagerServiceClient();
const gcpSecretsLoader = async (secretName: string) => {
try {
const secret = await client.accessSecretVersion({
name: `projects/my-app/secrets/${secretName}/versions/latest`,
});
const payload = secret.payload.data.toString("utf8");
console.info(`Payload: ${payload}`);
} catch (err) {
console.log(err);
}
};
gcpSecretsLoader("CLIENT_ID"); // CLIENT_ID matched a secret name within the secret manager
GOOGLE_APPLICATION_CREDENTIALS
to point to the service account JSON key file or specify the service account JSON key file when creating the Secret Manager clientSecretManagerServiceClient()
. Reviewoptions.keyFilename
in github.com/googleapis/nodejs-secret-manager/blob/master/src/v1/… – Brittenybrittinghamdetails: "Permission 'secretmanager.versions.access' denied for resource...
I checked and the string I passed in matches the exact name of the secret (in my code above this is "CLIENT_ID". – Leadinggcloud auth application-default login
. – Horntailfirebase functions:config:set
; however, considering my inexperience outside the realm of Firebase perhaps it's smarter for me just to stick withfirebase functions:config:set
. – Leading