From 31e0ac1ee8c9f245a2e3ca973b6cb3837b15e42a Mon Sep 17 00:00:00 2001 From: cutestnekoaqua Date: Sat, 11 Feb 2023 01:17:35 +0100 Subject: [PATCH] parse client id --- packages/backend/src/server/index.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/server/index.ts b/packages/backend/src/server/index.ts index 957854423c..adadc92c41 100644 --- a/packages/backend/src/server/index.ts +++ b/packages/backend/src/server/index.ts @@ -148,6 +148,7 @@ mastoRouter.get("/oauth/authorize", async (ctx) => { mastoRouter.post("/oauth/token", async (ctx) => { const body: any = ctx.request.body; + let client_id: any = ctx.request.query.client_id; const BASE_URL = `${ctx.request.protocol}://${ctx.request.hostname}`; const generator = (megalodon as any).default; const client = generator("misskey", BASE_URL, null) as MegalodonInterface; @@ -159,11 +160,16 @@ mastoRouter.post("/oauth/token", async (ctx) => { return; } } + if (client_id instanceof Array) { + client_id = client_id.toString();; + } else if (!client_id) { + client_id = null; + } try { const atData = await client.fetchAccessToken( - null, + client_id, body.client_secret, - m ? m[0] : null, + m ? m[0] : '', ); ctx.body = { access_token: atData.accessToken,