firebase - 创建用户服务器端 Firebase 函数

标签 firebase firebase-authentication

我正在尝试使用 Firebase 云功能创建到服务器端的登录 GET 请求。

是否可以使用 firebase 函数进行身份验证?我在函数文件夹中尝试了 npm i firebase,但它无法工作。

是否可以选择使用服务器端代码创建用户?

最佳答案

要从 Cloud Functions 中创建 Firebase 身份验证用户,请使用 Node.js 的 Firebase Admin SDK

要安装它,请遵循 instructions in the documentation 。主要是:

$ npm install firebase-admin --save

然后使用以下方法将其导入到您的index.js中:

var admin = require("firebase-admin");

要创建用户,请遵循 instructions in this documentation :

admin.auth().createUser({
  email: "user@example.com",
  emailVerified: false,
  phoneNumber: "+11234567890",
  password: "secretPassword",
  displayName: "John Doe",
  photoURL: "http://www.example.com/12345678/photo.png",
  disabled: false
})
  .then(function(userRecord) {
    // See the UserRecord reference doc for the contents of userRecord.
    console.log("Successfully created new user:", userRecord.uid);
  })
  .catch(function(error) {
    console.log("Error creating new user:", error);
  });

关于firebase - 创建用户服务器端 Firebase 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47268411/

相关文章:

node.js - 当我尝试在本地运行函数时 firebase 显示错误

javascript - Firebase 获取单个项目

swift - Firebase 身份验证获取用户个人资料

java - 无法使用最新的 Firebase 版本创建用户。我得到一个 W/DynamiteModule 和 W/GooglePlayServicesUtil

firebase - 有没有办法确定 Firebase 用户的 UID 是否有效?

android - firebase 记录的空用户 ID

swift - IOS FirebaseUI 登录自定义

android - 当我点击在后台运行的通知时,它总是调用 MainActivity ,我如何调用我的 WebVIew

firebase - 我的 firebase 用户身份验证中的未知用户 (Flutter/firebase)

javascript - 为什么我的容器组件不能正确接收 Async Await 的结果?