【发布时间】:2018-06-20 06:31:24
【问题描述】:
我需要使用这里的 Node.js API 文档中描述的Auth 类的revokeRefreshTokens 方法:https://firebase.google.com/docs/reference/admin/node/admin.auth.Auth#revokeRefreshTokens
它包含在 firebase-admin 包中,我根据https://www.npmjs.com/package/firebase-admin#installation 的文档使用 npm 命令安装了该包:
npm install --save firebase-admin
执行此操作并进入安装目录并检查 auth.js 文件,我发现该方法丢失了。我在哪里可以找到这个在 Firebase Cloud Functions 中使用的 revokeRefreshTokens 方法?
最初,我还尝试使用以下方法在我的 Cloud Function 中调用该方法:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
//Some additional code here to fetch the userRecord...
admin.auth().revokeRefreshTokens(userRecord.uid)
.then(function() {
console.log("Successfully revoked token");
})
.catch(function(error) {
console.log("Error revoking token:", error);
});
这给出了一个错误提示
TypeError: admin.auth(...).revokeRefreshTokens 不是函数。
如果需要任何进一步的信息,请告诉我。
【问题讨论】:
标签: node.js firebase firebase-authentication google-cloud-functions firebase-admin