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

**URL:** <https://community.auth0.com/t/retrieving-auth0-credentials-from-azure-key-vault-in-next-js-14/150155>\
**Category:** Dev to Dev Hub\
**Tags:** login-experience, new-universal-login-experience\
**Created:** [October 20, 2024, 1:53pm UTC](https://community.auth0.com/t/retrieving-auth0-credentials-from-azure-key-vault-in-next-js-14/150155 "2024-10-20T13:53:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![visconde](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@visconde](https://community.auth0.com/u/visconde)\
**Post date:** [October 20, 2024, 1:53pm UTC](https://community.auth0.com/t/retrieving-auth0-credentials-from-azure-key-vault-in-next-js-14/150155/1 "2024-10-20T13:53:08Z")

</div>

Hello Auth0 community,

I’m working on a Next.js 14 application and I’m trying to improve the security of my Auth0 integration. My goal is to retrieve the `client_id` and `client_secret` from Azure Key Vault instead of storing them in a local .env file.

I’m using the Auth0 SDK for Next.js and have set up a custom `handleAuth` route. Initially, I thought I could simply fetch the credentials from Azure Key Vault and pass them directly to the `handleLogin` function like this:

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

```

However, I’ve encountered two issues:

1. Despite the TypeScript intellisense suggesting that `client_id` is a valid property for `authorizationParams`, when I add it, I still get a console error: “Uncaught Error: “clientID” is required”.
2. The official Auth0 documentation doesn’t list `client_id` as a property of `AuthorizationParams`.

This leads me to two questions:

1. Is the Next.js Auth0 SDK’s TypeScript definition potentially misleading by suggesting `client_id` as a valid property?
2. What’s the correct way to provide the `client_id` (and potentially `client_secret`) to the Auth0 SDK when they’re fetched from an external source like Azure Key Vault, rather than being stored in environment variables?

I’d greatly appreciate any insights or best practices for securely integrating Auth0 with Azure Key Vault in a Next.js 14 application. Thank you in advance for your help!

---

<div class="post-metadata">

**Author:** ![teodor.andrei](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/teodor.andrei/32/75320_2.png) [@teodor.andrei](https://community.auth0.com/u/teodor.andrei)\
**Post date:** [April 29, 2025, 8:20am UTC](https://community.auth0.com/t/retrieving-auth0-credentials-from-azure-key-vault-in-next-js-14/150155/3 "2025-04-29T08:20:38Z")

</div>

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

To answer your first question, the `AuthorizationParams` [interface](https://github.com/auth0/nextjs-auth0/blob/main/src/types/index.ts) does not contain a `client_id` property.

```auto
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](https://github.com/auth0/nextjs-auth0/#:~:text=Customizing%20the%20client) for more information.

```auto
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](https://learn.microsoft.com/en-us/azure/key-vault/secrets/quick-create-node?tabs=azure-cli%2Cwindows&pivots=programming-language-typescript) .

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!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [May 13, 2025, 8:20am UTC](https://community.auth0.com/t/retrieving-auth0-credentials-from-azure-key-vault-in-next-js-14/150155/4 "2025-05-13T08:20:39Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

**Author:** ![remus.ivan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/remus.ivan/32/68771_2.png) [@remus.ivan](https://community.auth0.com/u/remus.ivan)\
**Post date:** [September 5, 2025, 8:39pm UTC](https://community.auth0.com/t/retrieving-auth0-credentials-from-azure-key-vault-in-next-js-14/150155/5 "2025-09-05T20:39:57Z")

</div>


