From ad8d0a4e774588b285bbccab4a5eb501d8ab2a9d Mon Sep 17 00:00:00 2001 From: Cheng CHENG Date: Wed, 31 Aug 2022 01:08:29 +0800 Subject: [PATCH] fix: lark calendar get app access token bug (#4043) Co-authored-by: chengcheng.frontend --- packages/app-store/larkcalendar/api/events.ts | 3 ++- packages/app-store/larkcalendar/lib/AppAccessToken.ts | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/app-store/larkcalendar/api/events.ts b/packages/app-store/larkcalendar/api/events.ts index 30d1822853..12246ae146 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 32acfd1605..e151352396 100644 --- a/packages/app-store/larkcalendar/lib/AppAccessToken.ts +++ b/packages/app-store/larkcalendar/lib/AppAccessToken.ts @@ -32,6 +32,10 @@ function makePoolingPromise( 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> => {