[英]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.