gpt4 book ai didi

node.js - 错误: Credential implementation provided to initializeApp() via the "credential" property failed to fetch a valid Google OAuth2 access token

转载 作者:太空宇宙 更新时间:2023-11-04 01:23:44 30 4
gpt4 key购买 nike

    const admin = require('firebase-admin');
require('dotenv').config()
// const serviceAccount = require("../service-account-file.json");
const check = process.env.GOOGLE_APPLICATION_CREDENTIALS;
//GOOGLE_APPLICATION_CREDENTIALS="/home/byordani93/tuDiagram/service-account-file.json"
console.log(check, 'mate')

admin.initializeApp({
projectId: 'tudiagram',
credential: admin.credential.applicationDefault(check),
databaseURL: 'https://tudiagram.firebaseio.com'
});

module.exports = admin;

然后消息


> (node:3218) UnhandledPromiseRejectionWarning: Error: Credential
> implementation provided to initializeApp() via the "credential"
> property failed to fetch a valid Google OAuth2 access token with the
> following error: "Error fetching access token: Error while making
> request: The "options.agent" property must be one of type Agent-like
> Object, undefined, or false. Received type string. Error code:
> ERR_INVALID_ARG_TYPE".
>

I tried making the env value a string and not a string as well as checking to see if the process.env was being detected and still nothing not sure at this point I have googled to no avail please give some pointers or tips **hint hint maybe a solution haha :)

最佳答案

试试这个

    import * as firebase  from 'firebase-admin';
const serviceAccount = require("../../serviceAccountKey.json")

firebase.initializeApp({
credential: firebase.credential.cert(serviceAccount),
databaseURL: 'https://xxxxxx.firebaseio.com'
});

applicationDefault更改为cert

关于node.js - 错误: Credential implementation provided to initializeApp() via the "credential" property failed to fetch a valid Google OAuth2 access token,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58261601/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com