Skip to content

Commit eb7bdc6

Browse files
committed
Add connectToken endpoint (connect-next playground)
1 parent ff4c3da commit eb7bdc6

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

  • playground/connect-next/app/(api)/connectToken
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { NextRequest } from 'next/server';
2+
import { getCorbadoConnectToken, verifyAmplifyToken } from '@/lib/utils';
3+
4+
type Payload = {
5+
idToken: string;
6+
connectTokenType: string;
7+
};
8+
9+
export async function POST(req: NextRequest) {
10+
const body = (await req.json()) as Payload;
11+
12+
const { idToken, connectTokenType } = body;
13+
14+
const { displayName, identifier } = await verifyAmplifyToken(idToken);
15+
16+
const connectToken = await getCorbadoConnectToken(connectTokenType, {
17+
displayName: displayName,
18+
identifier: identifier,
19+
});
20+
21+
return new Response(JSON.stringify({ token: connectToken }), {
22+
status: 201,
23+
headers: { 'Content-Type': 'application/json' },
24+
});
25+
}

0 commit comments

Comments
 (0)