Skip to main content
AppAlert

AADSTS7000222: client secret expired

Reviewed

On this page
Error message returned by Microsoft Entra
AADSTS7000222: The provided client secret keys for app '<application-id>' are expired. Visit the Azure portal to create new keys for your app: https://aka.ms/NewClientSecret, or consider using certificate credentials for added security: https://aka.ms/certCreds.

What the message means

The app asked Microsoft Entra ID (formerly Azure AD) for a token with a client secret that has passed its expiry date. Microsoft's error reference lists the code as InvalidClientSecretExpiredKeysProvided: "The provided client secret keys are expired."

The token request fails, so everything the app does with that secret stops: API calls, scheduled jobs, deployments. The message names the app by its application (client) ID. Start with that ID, because the app you think is failing is not always the one in the message.

Microsoft notes that error codes and messages can change. Match the message text as well as the code.

Which case is yours

No valid secret exists on the app. The app registration lists only expired secrets under Certificates & secrets. Create a replacement and roll it out. The client secret renewal guide has the full procedure.

A new secret exists, but the workload still sends the old one. Someone already renewed the secret in Entra, yet the error continues. Microsoft's AKS troubleshooting article describes this case: "A valid replacement might already exist in Entra but hasn't been applied." Find the copy that was not updated, using the list in Where the old credential still lives.

The secret was renewed on a different app. Compare the application ID in the message with the app you renewed. If they differ, the failing workload uses another app registration.

The failure comes from an Azure DevOps pipeline. A service connection keeps its own copy of the secret. Follow Azure DevOps service connection secret expired.

Fix it

  1. Read the application ID from the message. List that app's secrets and their expiry dates with Azure CLI. The output shows metadata only. Nobody can read a secret value back after creation.

    az ad app credential list --id '<application-id>' --output table
    

    In the portal, open App registrations, select the app, then Certificates & secrets, Client secrets.

  2. If every secret has expired, add a new one next to the old ones. With Azure CLI, pass --append to az ad app credential reset; without it, the command replaces the existing secrets. Copy the value into your secret store straight away. Microsoft shows the value only once.

  3. Update every consumer of the secret, then test a fresh token request from each one. An app that still holds a cached token can look healthy until that token runs out.

  4. Check which key ID each consumer now uses. Identify the active credential shows how to read it from the service principal sign-in logs.

  5. Delete the expired secret by its key ID once every consumer uses the new one.

Where the old credential still lives

A secret is copied into every system that signs in with it. Renewing it in Entra changes none of these copies. Check each one that applies:

  • Key Vault secrets and the apps that read them at startup.
  • App settings and environment variables in App Service, Functions, and container platforms.
  • Azure DevOps service connections and variable groups, and secrets in other CI systems.
  • AKS clusters that sign in with a service principal. Update the cluster credentials after you renew the secret.
  • Configuration files and scheduled tasks on servers and integration hosts.
  • Third-party products that store the client ID and secret in their own settings.

Prevent the next one

Decide who renews the secret and how much notice they need before it expires. In the portal, a secret lasts at most 24 months. Microsoft recommends less than 12 months, and certificates or federated credentials instead of secrets for production.

Microsoft's own expiry emails cover only some credential types and recipients. See App secret expiration notifications for what Entra sends and to whom. To build your own checks, use Monitor Entra app credential expiration.

FAQ

Does deleting the expired secret fix AADSTS7000222?

No. Deleting it only changes the error. A workload that still sends a secret deleted from Entra gets AADSTS7000215 (invalid client secret) instead. Update the consumer to the new value first.

What is the difference between AADSTS7000222 and AADSTS7000215?

AADSTS7000222 means Entra recognized the secret, but it has expired. AADSTS7000215 means the value matches no current secret on the app: a typo, the secret ID instead of the value, a value for another app, or a deleted secret. See AADSTS7000215.

Can I extend the expiry date of an existing secret?

No. Add a new secret with the expiry you want, roll it out, and then delete the old one. The procedure is in the client secret renewal guide.

How long do Entra client secrets last?

The portal offers lifetimes up to 24 months. Microsoft recommends less than 12 months. Graph and Azure CLI use their own defaults when you do not set an end date, and they accept a later end date unless an application management policy restricts secret lifetimes.