From 4e2b2eeeaa65164ac2cdd12ec95aff255e31884e Mon Sep 17 00:00:00 2001 From: Mikkel Jakobsen Date: Fri, 15 Nov 2024 20:14:14 +0100 Subject: [PATCH] Trying to use current url in authorizationCodeGrant --- app/auth/callback/unilogin/route.ts | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/app/auth/callback/unilogin/route.ts b/app/auth/callback/unilogin/route.ts index 644ccab0..e5ebe088 100644 --- a/app/auth/callback/unilogin/route.ts +++ b/app/auth/callback/unilogin/route.ts @@ -1,4 +1,3 @@ -import { NextRequest } from "next/server" import * as client from "openid-client" import goConfig from "@/lib/config/config" @@ -13,26 +12,18 @@ export interface TIntrospectionResponse extends client.IntrospectionResponse { institutionIds: string } -export async function GET(request: NextRequest) { +export async function GET() { const session = await getSession() const config = await getUniloginClientConfig() - const currentUrl = new URL(request.url) - const appUrl = goConfig("app.url") - const redirect_uri = `${appUrl}/auth/callback/unilogin` + const appUrl = goConfig("app.url") + const currentUrl = new URL(`${appUrl}/auth/callback/unilogin`) // Fetch all user/token info. try { - const tokenSetResponse = await client.authorizationCodeGrant( - config, - currentUrl, - { - pkceCodeVerifier: session.code_verifier, - idTokenExpected: true, - }, - { - redirect_uri, - } - ) + const tokenSetResponse = await client.authorizationCodeGrant(config, currentUrl, { + pkceCodeVerifier: session.code_verifier, + idTokenExpected: true, + }) const tokenSet = schemas.tokenSet.parse(tokenSetResponse) as TTokenSet