在哪里可以找到包含 revokeRefreshTokens 方法的 firebase-admin 包?
Where can I find the firebase-admin package which contains the revokeRefreshTokens method?
我需要使用 Node.js API 文档中描述的 Auth
class 的 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 文件时,我发现缺少该方法。我在哪里可以找到这个 revokeRefreshTokens
在 Firebase Cloud Functions 中使用的方法?
最初,我还尝试使用以下方法在我的 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 is not a function.
如果需要任何进一步的信息,请告诉我。
确保您安装的是最新版本 (5.7.0)。如果这样做,您将在 node_modules/firebase-admin/lib/auth/auth.js
(第 295 行左右)中找到以下内容:
/**
* Revokes all refresh tokens for the specified user identified by the provided UID.
* In addition to revoking all refresh tokens for a user, all ID tokens issued before
* revocation will also be revoked on the Auth backend. Any request with an ID token
* generated before revocation will be rejected with a token expired error.
*
* @param {string} uid The user whose tokens are to be revoked.
* @return {Promise<void>} A promise that resolves when the operation completes
* successfully.
*/
Auth.prototype.revokeRefreshTokens = function (uid) {
return this.authRequestHandler.revokeRefreshTokens(uid)
.then(function (existingUid) {
// Return nothing on success.
});
};
我需要使用 Node.js API 文档中描述的 Auth
class 的 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 文件时,我发现缺少该方法。我在哪里可以找到这个 revokeRefreshTokens
在 Firebase Cloud Functions 中使用的方法?
最初,我还尝试使用以下方法在我的 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 is not a function.
如果需要任何进一步的信息,请告诉我。
确保您安装的是最新版本 (5.7.0)。如果这样做,您将在 node_modules/firebase-admin/lib/auth/auth.js
(第 295 行左右)中找到以下内容:
/**
* Revokes all refresh tokens for the specified user identified by the provided UID.
* In addition to revoking all refresh tokens for a user, all ID tokens issued before
* revocation will also be revoked on the Auth backend. Any request with an ID token
* generated before revocation will be rejected with a token expired error.
*
* @param {string} uid The user whose tokens are to be revoked.
* @return {Promise<void>} A promise that resolves when the operation completes
* successfully.
*/
Auth.prototype.revokeRefreshTokens = function (uid) {
return this.authRequestHandler.revokeRefreshTokens(uid)
.then(function (existingUid) {
// Return nothing on success.
});
};