Why isn't my Firebase app connecting to Google Secret Manager?

 ̄綄美尐妖づ 提交于 2021-02-11 15:12:13

问题


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 my-app@appspot.gserviceaccount.com 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

来源:https://stackoverflow.com/questions/61858504/why-isnt-my-firebase-app-connecting-to-google-secret-manager

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!