About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.
AADSTS7000222 is Microsoft Entra ID telling a service, scheduled task or web application that the client secret it sent is past its end date. Microsoft's error reference names it InvalidClientSecretExpiredKeysProvided and says: "The provided client secret keys are expired. Create new keys for your app, or consider using certificate credentials for added security: https://aka.ms/certCreds".
The fix is to add a new credential to the app registration, put the new value where the application reads it, confirm sign-in works, and only then remove the expired credential. Microsoft's credential page says client secrets "should not be used in production environments" and recommends a certificate, so a new secret is a stopgap and the repair is also a chance to move off secrets.
What the error means
A confidential client application (one that can keep a credential, such as a service on a server) proves who it is to Microsoft Entra ID with a client secret, a certificate or a federated credential. A client secret is a string value that Microsoft's credential page describes as "sometimes called an application password". Every client secret has an expiry date. After that date Entra ID rejects it with this error.
The error codes are close together, so confirm which one you have:
| Code | Microsoft's description |
|---|---|
| AADSTS7000222 | InvalidClientSecretExpiredKeysProvided: the provided client secret keys are expired |
| AADSTS7000215 | Invalid client secret is provided. Developer error: the app is attempting to sign in without the necessary or correct authentication parameters |
| AADSTS7000218 | The request body must contain the following parameter: 'client_assertion' or 'client_secret' |
| AADSTS700027 | Client assertion failed signature validation |
| AADSTS50012 | AuthenticationFailed, with several certificate causes such as an unauthorised subject name or thumbprint |
Only AADSTS7000222 is an expiry. If your error is 7000215, the secret value the application sends is wrong, which can follow a rotation where the application kept the old value.
Client secret lifetime is limited by Microsoft's credential page to 24 months or less, and Microsoft recommends under 12 months. If the secret in the portal shows a date in the past, this error is the expected result.
Likely causes
| Cause | What you see | How to confirm |
|---|---|---|
| The only client secret on the app registration has expired | Sign-in fails with AADSTS7000222 from every instance of the app | Certificates & secrets shows the end date in the past |
| The application still holds an older secret after a rotation | AADSTS7000222 (old, expired value) or AADSTS7000215 (wrong value) | A newer unexpired secret exists but the app's stored value does not match it |
| Several copies of the app configuration, only some updated | Works on one server, fails on another | Compare the stored secret on each host |
| A service connection or platform owns the secret | Updating the portal alone does not fix it | Microsoft notes some Azure DevOps service connections need the secret updated from that service |
| Wrong app registration | Rotation was done on a different registration | Compare the Application (client) ID in the app's configuration with the portal |
Prove the cause before changing anything
Copy the Application (client) ID from the failing application's configuration. In the Microsoft Entra admin center, go to App registrations, select the application, then Certificates & secrets. Compare the end date of each client secret with today's date.
Match the client ID. Microsoft's Graph pages separate two identifiers: the object ID (
id) of the application and its application (client) ID (appId). Graph PowerShell's-ApplicationIdparameter takes the object ID, with the aliasObjectId. To find the object ID from a client ID, use the documented filter form:Connect-MgGraph -Scopes 'Application.Read.All' Get-MgApplication -Filter "AppId eq '<client-id>'" | Format-List Id, DisplayName, AppIdUse the
Idit returns in later commands.Read the application's own error log for the first AADSTS7000222 and note its time. The first failure should fall just after the end date of the secret you found in step 1. A first failure well before that date points to a different credential or a different registration.
On the server, find where the application stores its secret (a configuration file, a service credential, a scheduled task's stored credential or a secrets store) and record every location before you change anything.
The result that confirms this diagnosis is a registration with no unexpired secret, or an unexpired secret whose value differs from the one the application stores. The result that rules it out is an unexpired secret that the application already uses. In that case the error is not an expiry, so compare your error with the other codes in the table.
If the application runs under a platform that manages the credential for you, update the secret there. Microsoft's note says that for an Azure DevOps service connection that creates its own service principal, you "need to update the client secret from the Azure DevOps portal site instead of directly updating the client secret."
Fix
Who can do it. For delegated access, Microsoft's addPassword page lists these roles: a member user for applications they own, Application Developer for applications they own, Cloud Application Administrator and Application Administrator.
Preferred: replace the secret with a certificate. Microsoft's credential page says: "Microsoft recommends that you use a certificate instead of a client secret before moving the application to a production environment." In the portal, open Certificates & secrets, then Certificates, then Upload certificate, choose a .cer, .pem or .crt file, select Add and record the thumbprint. In production, Microsoft says to use a certificate signed by a well-known certificate authority and Azure Key Vault to manage access and lifetime.
Risk: the application must be changed to sign in with the certificate, and its private key must be installed on the server. Back out by keeping the old credential in place until the new one works.
Workload running outside a certificate-friendly host. Microsoft's credential page describes federated identity credentials as letting workloads such as GitHub Actions, Kubernetes or compute outside Azure access protected resources "without needing to manage secrets". In the portal this is Certificates & secrets, Federated credentials, Add credential. It applies where the platform can issue its own tokens. For a Windows service on a file server, a certificate is the more direct choice.
Risk: adding a federated credential changes how the workload is trusted and takes effect only once the workload is set up to use it. Back out by keeping the old credential in place until the new one works.
Add a new client secret (portal). Certificates & secrets, Client secrets, New client secret, add a description, set an expiry (Microsoft recommends under 12 months; the limit is 24), select Add. Record the secret Value straight away. Microsoft says the value is "never displayed again" after you leave the page.
Risk: this adds a second credential and removes nothing, so the expired one is untouched. If you leave the page before recording the Value, it cannot be shown again; back out by adding another secret.
Add a new client secret (PowerShell). This is Microsoft's own example of a six-month secret:
Connect-MgGraph -Scopes 'Application.ReadWrite.All'
$appObjectId = '<object-id>'
$passwordCred = @{
displayName = 'Created in PowerShell'
endDateTime = (Get-Date).AddMonths(6)
}
$secret = Add-MgApplicationPassword -applicationId $appObjectId -PasswordCredential $passwordCred
$secret | Format-List
Risk: this adds a credential; it does not remove anything. The SecretText property holds the new value. Microsoft says the generated value is only returned at creation and "There is no way to retrieve this password in the future." Store it in your secrets store before closing the session. Back out by removing the new credential by its KeyId.
Give the application the new value. Update every location you recorded, then restart the service or recycle the application pool so the new value is read.
Disruptive step: restarting a production service interrupts the work it is doing. Choose a quiet time. Back out by restarting with the previous configuration, though that configuration still holds the expired secret.
Remove the expired secret after confirming. Expired secrets no longer authenticate, so removal is tidy-up.
Disruptive step: Remove-MgApplicationPassword removes a password from the application. Microsoft's page documents no way to restore a removed password, so treat it as having no way back, other than adding a new secret. Remove only an entry you have confirmed is expired and unused.
Connect-MgGraph -Scopes 'Application.ReadWrite.All'
$appObjectId = '<object-id>'
$params = @{
keyId = '<key-id>'
}
Remove-MgApplicationPassword -ApplicationId $appObjectId -BodyParameter $params
Use the same object ID as in the earlier commands (the Id value, not the client ID). The <key-id> is the keyId of the credential to remove. Microsoft's addPassword page shows a keyId in the response for each secret it creates, and the Remove page takes the same name in its example. If you cannot identify the key ID of the expired entry, leave the entry in place: an expired secret no longer authenticates, so removing it is tidy-up only.
Example (illustrative): app01 runs a nightly export for CONTOSO as the app registration contoso-export. Its client secret, created on 2025-11-14 with a 12-month expiry, ended on 2026-11-14. From 2026-11-15 the export fails with AADSTS7000222. On 2026-11-18 the administrator adds a new secret with AddMonths(6), which ends on 2027-05-18. The configuration on app01 is updated, the service is restarted and the next run signs in. A reminder is set for 2027-04-18, 30 days before the new end date.
Confirm the fix
- Start the application and trigger one sign-in. The error should not return in the sign-in log.
- In Certificates & secrets, confirm the new credential's end date and that the expired one is gone or clearly labelled.
- Confirm that every server or service that held the old value now holds the new one.
- If you moved to a certificate, confirm the thumbprint in the portal matches the installed certificate.
What to watch afterwards
- Put the new end date, the application name, its owner and the places the value lives in the same inventory you use for certificates.
- Set a reminder well before the end date. A six-month secret needs two rotations a year; a certificate or federated credential reduces that work.
- Give the registration at least two owners so a departure does not leave it unmanaged.
- Check the other registrations that use secrets. Microsoft's credential page links guidance on migrating applications away from secret-based authentication, and says client secrets are "less secure than certificate or federated credentials".
Read next
Related articles you may want next.
- HostingExpiring certificates and secrets that silently break hosted applicationsHow to inventory TLS certificates, client credentials and application secrets before they lapse in steady-state hosted production—not only after an outage.Read article
- CloudEntra ID Conditional Access: tenant lockout, break-glass accounts and how to test policy safelyHow Conditional Access locks administrators out, how to build emergency accounts that work under mandatory MFA, and a safe order for testing policy.Read article
- HostingIdentity for hosted servers: extend your domain, build a new one, or use Entra IDWhich sign-in and directory design suits Windows servers moved to a hosting provider: extending the existing Active Directory domain, building a separate domain, or using Microsoft Entra services, with what each depends on.Read article
Risks and limits
These commands have not been run or lab-tested. The commands use the object ID of the application, not the client ID; using the wrong one targets a different object or returns an error.
Microsoft's page does not say how a given application picks among several credentials, so test sign-in with the one you intend before removing others. If the secret on the registration has not expired, compare the other codes in the table above and check which registration the application is really using.
Sources
- Microsoft Entra authentication and authorization error codes — Microsoft Learn, page dated 2025-02-03, accessed 18 November 2026
- Add and manage app credentials in Microsoft Entra ID — Microsoft Learn, page dated 2026-11-17, accessed 18 November 2026
- application: addPassword - Microsoft Graph v1.0 — Microsoft Learn, page dated 2025-09-04, accessed 18 November 2026
- Add-MgApplicationPassword — Microsoft Learn, date not shown, accessed 18 November 2026
- Get-MgApplication — Microsoft Learn, date not shown, accessed 18 November 2026
- Remove-MgApplicationPassword — Microsoft Learn, date not shown, accessed 18 November 2026
This article was originally published on .