简体   繁体   English

Firebase 具有用于文本到语音的谷歌应用程序凭据的云功能 API

[英]Firebase cloud functions with google application credentials for text to speech API

I am starting the Firebase emulators with我正在启动 Firebase 模拟器

set GOOGLE_APPLICATION_CREDENTIALS=c:\code\firebase-admin-sdk.json
firebase emulators:start

and the code in index.js is index.js 中的代码是

  const googleConfig = async () => {
  const auth = new GoogleAuth({
    scopes: "https://www.googleapis.com/auth/cloud-platform",
  });
  const client = await auth.getClient();
  const projectId = await auth.getProjectId();
  const url = `https://dns.googleapis.com/dns/v1/projects/${projectId}`;
  const res = await client.request({url});
  console.log(res.data);
};

let googleTextToSpeechClient;

async function globalConfig() {
  dotenv.config();
  admin.initializeApp({
    credential: admin.credential.applicationDefault(),
  });
  const db = admin.firestore();
  db.settings;
  await googleConfig();
  googleTextToSpeechClient = new googleTextToSpeech.TextToSpeechClient();
}

globalConfig();

google auth doesn't get the credentials. google auth 没有获得凭据。 In my google console the firebase-admin key is valid.在我的谷歌控制台中,firebase-admin 密钥是有效的。 do I need another key from google cloud or does the firebase admin key let you access all enabled APIs?我需要来自谷歌云的另一个密钥还是 firebase 管理密钥允许您访问所有已启用的 API?

The emulators are setting the variable for you so the GOOGLE_APPLICATIONS_CREDENTIALS doesn't have to be set at all.模拟器正在为您设置变量,因此根本不必设置 GOOGLE_APPLICATIONS_CREDENTIALS。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google Cloud Text To Speech API 强制发音为单词 - Google Cloud Text To Speech API force pronunciation as word 使用本机 JavaScript 向 Google Cloud 文本转语音 API 进行身份验证 - Authenticate to Google Cloud text-to-speech API using native JavaScript 用于本地开发的 Google Cloud Functions 凭据 - Google Cloud Functions Credentials for Local Development Google Cloud Speech to Text 准确性问题 - Google Cloud Speech to Text Accuracy Issue 如何将 Google Cloud 凭据导入 Firebase Cloud Function? - How to import Google Cloud credentials into a Firebase Cloud Function? Google Cloud 文本转语音字符数 - Google Cloud Text-To-Speech Character counts 在 Android 4.2 上运行 google cloud speech api - Running google cloud speech api on Android 4.2 如何允许团队成员使用我的 Google Cloud Speech-to-Text API 帐户? - How do I allow a team member to use my Google Cloud Speech-to-Text API account? 产品中的 GOOGLE_APPLICATION_CREDENTIALS 和 GOOGLE_CLOUD_PROJECT 设置 - GOOGLE_APPLICATION_CREDENTIALS and GOOGLE_CLOUD_PROJECT setup in prod 请求具有无效的身份验证凭据。 预期 OAuth 2 云语音中的访问令牌错误 api - Request had invalid authentication credentials. Expected OAuth 2 access token error in cloud speech api
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM