Files
cal.diy/apps/web/app/api/auth/oauth/me/route.ts
T
Benny JooandAnik Dhabal Babu 3ab053bf17 chore: migrate oauth APIs to app router (#19824)
* migrate api/auth/oauth/me

* migrate the rest

* fix

---------

Co-authored-by: Anik Dhabal Babu <[email protected]>
2025-03-10 17:56:53 +01:00

19 lines
605 B
TypeScript

import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
import isAuthorized from "@calcom/features/auth/lib/oAuthAuthorization";
async function handler(req: NextRequest) {
const requiredScopes = ["READ_PROFILE"];
const token = req.headers.get("authorization")?.split(" ")[1] || "";
const account = await isAuthorized(token, requiredScopes);
if (!account) {
return NextResponse.json({ message: "Unauthorized" }, { status: 401 });
}
return NextResponse.json({ username: account.name }, { status: 201 });
}
export { handler as GET, handler as POST };