Firebase函数signInWithCustomToken与Node.js一起未定义

所以我创build了一个自定义标记

const token = authRef.createCustomToken(options.userId, { app: appRootName, debug: !!options.debug }); 

然后尝试签入

 return authRef.signInWithCustomToken(token).then((user) => { return user; }); 

自定义创build令牌成功,但signInWithCustomToken吐出这个错误。

 TypeError: authRef.signInWithCustomToken is not a function 

这是针对nodejs的Firebase 3,并已设置服务帐户。 该应用程序已正确初始化(或者代币生成首先不起作用),这里有什么问题?

我得到了同样的错误,希望下面的代码可以解决你的问题。
小心使用apiKey或serverKey

 var firebase = require('firebase') firebase.initializeApp({ apiKey: '*******', databaseURL: 'https://*****.firebaseio.com' }) var customToken = '*********' firebase.auth().signInWithCustomToken(customToken).catch(function(error) { var errorMessage = error.message console.log(errorMessage) }) 

实际的问题是

authWithCustomToken

存在于firebase而不是在使用Firebase安全function时常用的firebase-admin