簡體   English   中英

無法使用 Firebase 身份驗證創建用戶

[英]Not able to create a user with Firebase Auth

我得到的錯誤:

this.auth.createUser 不是函數

根據文檔,我應該能夠像這樣創建一個用戶:

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
})

我的代碼:

   import app from 'firebase/app';
    import 'firebase/auth';

class Firebase {
  constructor() {
    app.initializeApp(firebaseConfig);

    this.auth = app.auth();
  }

      doCreateExistingUserAuth = (uid, email, password) =>
          this.auth.createUser({
            uid: uid,
            email: email,
            password: password
          })

當我執行此操作時,出現上述錯誤。 任何想法我做錯了什么?

您鏈接到的文檔適用於 Firebase Admin SDK,僅適用於后端。 對於前端 Web 應用程序,無法創建新用戶。 如果您希望用戶能夠創建另一個用戶帳戶,則必須調用某個后端,在那里您可以使用 Admin SDK。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM