signInWithEmailandPassword

signInWithEmailandPassword

我开始使用带有Firebase的Cloud Functions编写代码。
在以下功能中,testCreateUserAccount成功。
testLogin在运行时失败,并显示类型错误,指出“ signInWithEmailAndPassword不是函数”

从我在文档中看到的内容来看,createUser与signInWithEmailAndPassword属于同一类,因此我不清楚为什么尝试调用signInWithEmailAndPassword会失败。有任何想法吗?谢谢!

"use strict";

var functions = require('firebase-functions');
const admin = require('firebase-admin');

admin.initializeApp(functions.config().firebase);

exports.testCreateUserAccount = functions.https.onRequest ((req, res) => {
    var email = "[email protected]";
    var password = "joejoe";

    admin.auth().createUser({
      email: email,
      password: password,
      disabled: false
    });
} );


exports.testLogin = functions.https.onRequest ((req, res) => {
    var email = "[email protected]";
    var password = "joejoe";

    admin.auth().signInWithEmailAndPassword(email, password);
} );

最佳答案

您在服务器端使用了admin.auth().signInWithEmailAndPassword(email, password),必须在客户端使用它。

10-06 12:36