Skip to content

Scheduling infrastructure for absolutely everyone.

fix: lark calendar get app access token bug (#4043)

Cheng CHENGad8d0a4e7745
diff --git a/packages/app-store/larkcalendar/api/events.ts b/packages/app-store/larkcalendar/api/events.ts
index 30d18228531..12246ae1462 100644
--- a/packages/app-store/larkcalendar/api/events.ts
+++ b/packages/app-store/larkcalendar/api/events.ts
@@ -55,7 +55,8 @@ async function postHandler(req: NextApiRequest, res: NextApiResponse) {
// used for events handler binding in lark open platform, see
// https://open.larksuite.com/document/ukTMukTMukTM/uUTNz4SN1MjL1UzM?lang=en-US
- if (req.body.type === "url_verification") {
+ if (req.body.type === "url_verification" && req.body.token === open_verification_token) {
+ log.debug("update token", req.body);
return res.status(200).json({ challenge: req.body.challenge });
}
diff --git a/packages/app-store/larkcalendar/lib/AppAccessToken.ts b/packages/app-store/larkcalendar/lib/AppAccessToken.ts
index 32acfd16056..e1513523960 100644
--- a/packages/app-store/larkcalendar/lib/AppAccessToken.ts
+++ b/packages/app-store/larkcalendar/lib/AppAccessToken.ts
@@ -32,6 +32,10 @@ function makePoolingPromise<T>(
const appKeysSchema = z.object({
app_id: z.string().min(1),
app_secret: z.string().min(1),
+ app_access_token: z.string().optional(),
+ app_ticket: z.string().optional(),
+ expire_date: z.number().optional(),
+ open_verification_token: z.string().min(1),
});
const getValidAppKeys = async (): Promise<ReturnType<typeof getAppKeys>> => {