【发布时间】:2016-11-07 02:10:32
【问题描述】:
我不知道出了什么问题。我正在使用 Node.js 并尝试使用电子邮件/密码和 Google 身份验证登录。我已经在 Firebase 控制台中启用了所有这些。
npm Firebase 版本 - 3.1.0
部分代码:
var firebase = require('firebase');
var config = {
apiKey: "AIzaSyAH27JhfgCQfGmoGTdv_VaGIaX4P-qAs_A",
authDomain: "pgs-intern.firebaseapp.com",
databaseURL: "https://pgs-intern.firebaseio.com",
storageBucket: "pgs-intern.appspot.com",
};
firebase.initializeApp(config);
app.post('/login', function(req, res) {
var auth = firebase.auth();
firebase.auth().signInWithEmailAndPassword(req.body.login, req.body.password).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// ...
});
}
错误:firebase.auth(...).signInWithLoginAndPassword 不是函数 要么 错误:我写的时候,firebase.auth(...).GoogleAuthProviders 不是构造函数
firebase.auth().signInWithPopup(provider).then(function(result) {
// This gives you a Google Access Token. You can use it to access the Google API.
var token = result.credential.accessToken;
// The signed-in user info.
var user = result.user;
// ...
}).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// The email of the user's account used.
var email = error.email;
// The firebase.auth.AuthCredential type that was used.
var credential = error.credential;
// ...
});
我只是按照文档中的内容做了。
【问题讨论】:
-
我找到了一种解决方法,使用来自客户端的匿名用户身份验证。请详细说明您的用例,以便我可以据此编写答案。
标签: node.js firebase firebase-authentication