From 55e2359d886efc2789654d232f506dcdc4b9a15f Mon Sep 17 00:00:00 2001 From: Li Ye Date: Fri, 22 Sep 2023 14:39:34 +0800 Subject: [PATCH] feat(in-app): add lagecy xd access token support for /xd/in-app --- in-app/v1/src/App/index.tsx | 4 ++-- next/api/src/router/xd.ts | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/in-app/v1/src/App/index.tsx b/in-app/v1/src/App/index.tsx index 92078afff..6f9dcdfa6 100644 --- a/in-app/v1/src/App/index.tsx +++ b/in-app/v1/src/App/index.tsx @@ -82,10 +82,10 @@ export default function App() { '/api/2/users', params['anonymous-id'] ? { type: 'anonymous', anonymousId: params['anonymous-id'] } - : params['xd-user-id'] - ? { type: 'xd-user', id: params['xd-user-id'], accessToken: params['access-token'] } : params['xd-access-token'] ? { XDAccessToken: params['xd-access-token'] } + : params['xd-user-id'] + ? { type: 'xd-user', id: params['xd-user-id'], accessToken: params['access-token'] } : params['tds-credential'] ? { type: 'tds-user', diff --git a/next/api/src/router/xd.ts b/next/api/src/router/xd.ts index 43fa1702f..32a68de79 100644 --- a/next/api/src/router/xd.ts +++ b/next/api/src/router/xd.ts @@ -26,7 +26,7 @@ const pickFirst = (query: string | string[]) => (Array.isArray(query) ? query[0] const router = new Router(); router.get('/in-app', async (ctx) => { - const { client_id, user_id, access_token, sdk_lang, ...rest } = ctx.query; + const { client_id, user_id, access_token, xd_access_token, sdk_lang, ...rest } = ctx.query; if (!client_id) { throw new HttpError('client_id is required.'); } @@ -36,6 +36,7 @@ router.get('/in-app', async (ctx) => { url.searchParams.append('lang', lang); } const hash = new URLSearchParams(); + if (xd_access_token) hash.append('xd-access-token', pickFirst(xd_access_token)); if (access_token) hash.append('access-token', pickFirst(access_token)); if (user_id) hash.append('xd-user-id', pickFirst(user_id)); hash.append('fields', JSON.stringify({ ...rest, sdk_lang: lang }));