,
},
})
} // all works fine
//back-end api in app/api/auth/route.js (will eventually move to middleware)
import { SignJWT, createRemoteJWKSet, jwtVerify } from 'jose'
import { getKindeServerSession } from '@kinde-oss/kinde-auth-nextjs/server'
export async function GET(request: Request) {
//test validity of front-end JWT
const fetoken = getJwt(request)
const JWKS = createRemoteJWKSet(new URL('https://<my-kinde-name>/.well-known/jwks'))
const result = await jwtVerify(fetoken, JWKS, {
issuer: 'https://<my-kinde-name>.kinde.com',
requiredClaims: ['sub', 'email', 'org_code', 'permissions'],
}) // this successfully decodes and verifies the JWT
//*HOWEVER*
const { getAccessToken, isAuthenticated } = getKindeServerSession()
console.log(await getAccessToken()) // this logs "Invalid token specified" on the server
const isAuth = await isAuthenticated() //this returns false
<snip>
}
,
},
})
} // all works fine
//back-end api in app/api/auth/route.js (will eventually move to middleware)
import { SignJWT, createRemoteJWKSet, jwtVerify } from 'jose'
import { getKindeServerSession } from '@kinde-oss/kinde-auth-nextjs/server'
export async function GET(request: Request) {
//test validity of front-end JWT
const fetoken = getJwt(request)
const JWKS = createRemoteJWKSet(new URL('https://<my-kinde-name>/.well-known/jwks'))
const result = await jwtVerify(fetoken, JWKS, {
issuer: 'https://<my-kinde-name>.kinde.com',
requiredClaims: ['sub', 'email', 'org_code', 'permissions'],
}) // this successfully decodes and verifies the JWT
//*HOWEVER*
const { getAccessToken, isAuthenticated } = getKindeServerSession()
console.log(await getAccessToken()) // this logs "Invalid token specified" on the server
const isAuth = await isAuthenticated() //this returns false
<snip>
}