Skip to content

Commit

Permalink
Trying to use current url in authorizationCodeGrant
Browse files Browse the repository at this point in the history
  • Loading branch information
spaceo committed Nov 15, 2024
1 parent bf658e0 commit 4e2b2ee
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions app/auth/callback/unilogin/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { NextRequest } from "next/server"
import * as client from "openid-client"

import goConfig from "@/lib/config/config"
Expand All @@ -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<string>("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

Expand Down

0 comments on commit 4e2b2ee

Please sign in to comment.