简体   繁体   English

无法在 Cloud Functions 中初始化 Firebase admin sdk

[英]Cannot initialize Firebase admin sdk in Cloud Functions

I am trying to create a Firebase Cloud Function that uses the firebase admin SDK.我正在尝试创建一个 Firebase 云 Function 使用 firebase 管理员 ZF20E3C5E604C0AB3D6FAZDAZ。 However, when I deploy the function below and attempt the function I receive the error "INTERNAL".但是,当我在下面部署 function 并尝试 function 时,我收到错误“内部”。 In the logs on the Firebase dashboard I am seeing:在 Firebase 仪表板的日志中,我看到:

Unhandled error TypeError: admin.auth.updateUser is not a function

What am I missing?我错过了什么? Thanks in advance.提前致谢。

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

admin.initializeApp()

exports.updateUser = functions.https.onCall((data, context) => {
  admin.auth
    .updateUser({
      email: data.email,
      displayName: data.name,
      emailVerified: true
    })
    .then(userRecord => userRecord.uid)
    .catch(err => {
      throw new functions.https.HttpsError('unknown', err)
    })
})

This is how I am calling it on my client:这就是我在我的客户端上调用它的方式:

const updateUser = functions.httpsCallable('updateUser')
    updateUser({
      name: this.state.name,
      email: this.state.email,
      track: this.state.track,
      password: this.state.password
    })
      .then(res => {
        console.log(res)
      })
      .catch(err => {
        console.log(err)
      })

The correct syntax is admin.auth().updateUser(... with parentheses after auth .正确的语法是admin.auth().updateUser(...auth后面加上括号。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用打字稿初始化Firebase云功能中的管理员凭据? - How to initialize admin credentials in Firebase cloud functions, using typescript? 在 Firebase 功能管理 sdk 中找不到服务帐户 - cannot find service account in firebase functions admin sdk 如何在使用 Cloud Functions 时使用 Firebase Admin SDK 更改 Firebase 实时数据库中的数据? - How do I use Firebase Admin SDK to change data in Firebase Realtime Database while using Cloud Functions? Cloud Functions for Firebase firebase 部署错误:“解析触发器时出错:找不到模块‘firebase-admin’” - Cloud Functions for Firebase firebase deploy error: "Error parsing triggers: Cannot find module 'firebase-admin'" NodeJS示例 - Firebase云功能 - 实例化Admin SDK目录服务对象 - NodeJS Example - Firebase Cloud Functions - Instantiate an Admin SDK Directory service object 在单个 Firebase 项目中读取/写入多个 DB - 管理员 SDK Cloud Functions - Read/Write to multiple DBs in single Firebase Project - Admin SDK Cloud Functions 我可以通过 firebase 云功能管理员 SDK 访问 twitter 身份验证数据吗? 如果是这样,怎么做? - Can I access twitter auth data via firebase cloud functions Admin SDK? If so, how? Firebase 管理 SDK 不适用于 Cloud Scheduler (PubSub) - Firebase admin SDK not working on Cloud Scheduler (PubSub) Firebase 管理员 SDK,FCM 云消息传递 - Firebase Admin SDK, FCM Cloud Messaging Firebase的云功能:管理员与root查找 - Cloud Functions for Firebase: admin vs root lookups
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM