core/apps/webapp/app/routes/oauth.tokeninfo.tsx
Harshith Mullapudi c80303a851
OAuth for core (#28)
* Feat: add integrations access to OAuth apps

* Fix: generalize OAuth flow

---------

Co-authored-by: Manoj K <saimanoj58@gmail.com>
2025-07-23 13:03:13 +05:30

24 lines
699 B
TypeScript

import { type LoaderFunctionArgs, json } from "@remix-run/node";
import { oauth2Service } from "~/services/oauth2.server";
export const loader = async ({ request }: LoaderFunctionArgs) => {
const url = new URL(request.url);
const idToken = url.searchParams.get("id_token");
if (!idToken) {
return json(
{ error: "invalid_request", error_description: "Missing id_token parameter" },
{ status: 400 }
);
}
try {
const userInfo = await oauth2Service.getUserInfoFromIdToken(idToken);
return json(userInfo);
} catch (error) {
return json(
{ error: "invalid_token", error_description: "Invalid or expired ID token" },
{ status: 401 }
);
}
};