Files
calendar/apps/web/app/api/auth/oauth/me/route.ts
T
Benny JooandGitHub 87bc8d649a feat: add sentry report wrapper to every api route in appDir (#19966)
* update oauth tests

* fix parseRequestData

* add logging

* add fallback

* use ??

* updates

* use parseUrlFormData in saml/callback

* update tests

* fix

* remove log

* update

* any -> unknown

* use HttpErrors

* addressed

* unknown -> any

* feat: Add entry report wrapper to every api route in appDir

* fix

* fix unit test

* fix
2025-03-11 23:38:49 -04:00

20 lines
750 B
TypeScript

import { defaultResponderForAppDir } from "app/api/defaultResponderForAppDir";
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 const GET = defaultResponderForAppDir(handler);
export const POST = defaultResponderForAppDir(handler);