Firebase Functions 无法验证 AppCheck 令牌,即使刚刚更新,声明也已过时

Firebase Functions fail to validate AppCheck token, claims outdated even though just updated

我刚刚为我的 iOS 应用程序和 Firebase 云功能启用了 AppCheck。在 Firebase Functions 日志中,当我尝试 HTTPS 调用函数时收到此消息:

Failed to validate AppCheck token. Error: Cannot validate AppCheck token. Please update Firebase Admin SDK to >= v9.8.0
at checkTokens (/workspace/node_modules/firebase-functions/lib/providers/https.js:255:23)
at func (/workspace/node_modules/firebase-functions/lib/providers/https.js:323:39)
at /workspace/node_modules/firebase-functions/lib/providers/https.js:356:44
at cors (/workspace/node_modules/cors/lib/index.js:188:7)
at /workspace/node_modules/cors/lib/index.js:224:17
at originCallback (/workspace/node_modules/cors/lib/index.js:214:15)
at /workspace/node_modules/cors/lib/index.js:219:13
at optionsCallback (/workspace/node_modules/cors/lib/index.js:199:9)
at corsMiddleware (/workspace/node_modules/cors/lib/index.js:204:7)
at corsFunc (/workspace/node_modules/firebase-functions/lib/providers/https.js:356:16)


Callable request verification failed: AppCheck token was rejected. {"verifications":{"app":"INVALID","auth":"VALID"}}

但是,我已经使用 npm 命令更新了 Admin SDK,并多次部署了我的函数和整个 firebase 文件夹。 Admin SDK seems up to date.

这是我的 Firebase 函数的 Typescript 文件顶部的样子:

import * as functions from 'firebase-functions';
import * as admin from "firebase-admin";
import QuerySnapshot = admin.firestore.QuerySnapshot;
import { QueryDocumentSnapshot } from "firebase-functions/lib/providers/firestore";

有什么我没有做的事情来使更新后的 Admin SDK 生效吗?

你 运行 安装命令是否带有 --save 标志?如果这样做,您应该会在 package.json 中看到更新的版本。这可能是缺少的。

source

答案是我没有 运行 更新命令在 functions 子文件夹中,而是在我的主 firebase 文件夹中。