So I have an API and an application both using Auth0, I know the application can successfully authenticate with the api when I use the test curl command to get the access token. However when I try to use a user’s access token I am not able to authenticate and get a token without a payload. Here are the details:
Version: “@auth0/nextjs-auth0”: “^4.4.2”
auth0.ts:
import { Auth0Client } from "@auth0/nextjs-auth0/server"
export const auth0 = new Auth0Client({
enableAccessTokenEndpoint: true,
authorizationParameters: {
audience: "https://api.azuretestapp.com",
scope: "profile email openid offline_access"
}
});
export async function getAccessToken() {
const session = await auth0.getSession();
if (!session) {
throw new Error('Session not found');
}
const token = session.tokenSet.accessToken;
return token;
}
Based on my understanding of how this client version works (with limited examples in docs) this should work, however I don’t see what it wrong.
I also tried to use const accessToken = await getAccessToken()
which worked in previous versions of the client, however I now get: ‘TypeError: Failed to parse URL from /auth/access-token’
What am I doing wrong?