Skip to content

Commit

Permalink
feat(in-app): add lagecy xd access token support for /xd/in-app
Browse files Browse the repository at this point in the history
  • Loading branch information
leeyeh committed Oct 16, 2023
1 parent 0cfb258 commit 55e2359
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions in-app/v1/src/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 2 additions & 1 deletion next/api/src/router/xd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
}
Expand All @@ -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 }));
Expand Down

0 comments on commit 55e2359

Please sign in to comment.