Retrieving Auth0 credentials from Azure Key Vault in Next.js 14

Hi @visconde, and welcome back to the Auth0 Community!

To answer your first question, the AuthorizationParams interface does not contain a client_id property.

export interface AuthorizationParameters {
  /**
   * The scope of the access request, expressed as a list of space-delimited, case-sensitive strings.
   * Defaults to `"openid profile email offline_access"`.
   */
  scope?: string | null;
  /**
   * The unique identifier of the target API you want to access.
   */
  audience?: string | null;
  /**
   * The URL to which the authorization server will redirect the user after granting authorization.
   */
  redirect_uri?: string | null;
  /**
   * The maximum amount of time, in seconds, after which a user must reauthenticate.
   */
  max_age?: number;
  /**
   * Additional authorization parameters.
   */
  [key: string]: unknown;
}

When working with the NextJS SDK, the clientId and clientSecret properties need to be part of the object you pass to the handleAuth function (if not present in the .env file using the key AUTH0_CLIENT_ID). Also, notice that they are in camelCase as part of the SDK. See docs for more information.

export const GET = handleAuth({
  login: handleLogin({
    authorizationParams: {
      scope: 'openid profile email',
      redirect_uri: redirectUri,
    },
    returnTo: '/equipment',
  }),
  // ... other handlers
  clientId: clientId,
  clientSecret: clientSecret,
});

Before adding them here, make sure you fetch them from the Azure Key Vault properly using the Azure Key Vault secret client library for JavaScript .

The simplest way to check if you fetched them correctly is to add logs before using them in your handleAuth function:

console.log(“clientId:”, clientId);
console.log(“clientSecret:”, clientSecret);

If you have any more questions, don’t hesitate to come back!

1 Like