如何让用户使用带有nodejs的电子邮件和密码firebase

How to get user using email and password firebase with nodejs

如何使用带有用户电子邮件和密码的 firebase 身份验证获取用户数据?

我能够捕获用户的唯一方法是使用

firebase.auth() function.getUserByEmail(email)

但我找不到如何通过用户的电子邮件和密码执行该调用,对这个问题有帮助吗?

我的源代码:

var express = require('express');
var app = express();
const firebase = require('firebase-admin');
const inquirer = require('inquirer')
const serviceAccount = require('...')
var currentUser;
var userProfile;

var config = {
    credential: firebase.credential.cert(serviceAccount),
    apiKey: "...",
    authDomain: "...",
    databaseURL: "...",
    projectId: "...",
    storageBucket: "...",
    messagingSenderId: "..."
};

firebase.initializeApp(config);


    let server = app.listen('8081', function (err) {
        if (err) {
            console.log(err);
        }
        console.log("App listening on port " + "8081");

        var authentication = [
            {
                type: 'input',
                name: 'email',
                message: "Type your email:",
            },
            {
                type: 'password',
                name: 'password',
                message: "Type your password:",
            },
        ]

    inquirer.prompt(authentication).then(answers => {
        console.log(`Hello! The application is starting!`)
        startCrawler(answers['email'], answers['password'])
    })

    async () => {
        await firebase.auth().getUserByEmail(email) //Here where I want to grab the user with email and password
            .then((user) => {
                currentUser = user.toJSON();
            }).catch(err => {
                console.log('Email or password invalid!');
            });

        if (!currentUser) { return };
    }

});

您似乎正在尝试让用户登录使用 Firebase Admin SDK 的 Node.js 应用。 Firebase Admin SDK 没有登录用户的概念。如果您需要,请考虑为 Web 应用程序使用常规的 Firebase SDK。

另见我的回答:Firebase Admin SDK to Log user in from Server