I'm beginning writing code with Cloud Functions with Firebase . Of the functions below, testCreateUserAccount succeeds. testLogin fails with a Type Error at runtime, stating " signInWithEmailAndPassword is not a function "
From what I have seen in the documentation, createUser is under the same class as signInWithEmailAndPassword , so its not clear to me why attempting to call signInWithEmailAndPassword would fail. Any ideas? Thanks!
"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 = "joe@example.com";
var password = "joejoe";
admin.auth().createUser({
email: email,
password: password,
disabled: false
});
} );
exports.testLogin = functions.https.onRequest ((req, res) => {
var email = "joe@example.com";
var password = "joejoe";
admin.auth().signInWithEmailAndPassword(email, password);
} );
您在服务器端使用了admin.auth().signInWithEmailAndPassword(email, password)
,您必须在客户端使用它。
Now you could use the identitytoolkit's rest endpoint:
https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=[API_KEY]
Here you have the documentation:
You can use Identity toolkit REST API like this then response with idToken. IdToken can be use to verify an account using admin.auth().verifyIdToken(idToken)
in Cloud Function.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.