From the notebook
AADSTS7000215 Invalid Client Secret: Microsoft Entra Fix
Fix AADSTS7000215 invalid client secret errors by checking the secret value, app and tenant pairing, encoding, expiration, rotation, and sign-in evidence.
An AADSTS7000215 invalid client secret error means Microsoft Entra received a confidential-client authentication request but could not validate the credential presented for that client application. The reliable fix is to verify the deployed Application (client) ID, authority tenant, and client secret value as one matched set, then check how the running workload reads and encodes that value. Regranting API permissions, changing Conditional Access, or copying the secret's ID does not repair credential validation.
Grab a coffee and resist the tempting fix of creating secrets until one happens to work. First preserve the failed request, prove which application and tenant received it, and identify the configuration source used by the failing instance. Microsoft's error reference classifies AADSTS7000215 as an invalid client secret and a client-authentication parameter problem. Its confidential-client troubleshooting guidance starts with the same practical checks: use the secret value, confirm expiration, and rule out whitespace or encoding damage. (Microsoft Entra authentication error reference, confidential-client troubleshooting)
This guide is for Entra administrators and application owners troubleshooting an app-only job, daemon, web application, automation, or other confidential client. It focuses on evidence and safe recovery without exposing the credential or turning a narrow outage into an untracked application change.
AADSTS7000215 invalid client secret: the short answer
Work through these checks in order:
- Capture the exact error, UTC timestamp, request ID, correlation ID, token authority, client ID, deployment, and last successful time. Never capture the secret itself.
- Resolve the failed request's
client_idto the intended app registration and verify the token endpoint's tenant. - Confirm the workload uses the client secret Value, not its Secret ID, credential key ID, object ID, or description.
- Inspect the workload's effective runtime configuration—not only the repository, portal, or secret store—and compare its version with a working instance.
- Check expiration, activation timing, accidental whitespace, truncation, newline insertion, URL encoding, and stale deployment references.
- Add a replacement credential only after the mismatch is understood. Deploy and validate the new value before removing the old credential.
- Correlate the retest in service-principal sign-in logs and preserve the application-management audit evidence.
- After recovery, move Azure-hosted workloads to managed identity, suitable external workloads to workload identity federation, or production confidential clients to certificates where supported.
The order matters. AADSTS7000215 is a failure to prove the client's identity at the token endpoint. Microsoft Entra has not reached the question of what API permissions that client should receive.
Understand where AADSTS7000215 happens
A client-credentials request normally sends a tenant-specific token endpoint a client ID, a credential, a resource scope ending in /.default, and grant_type=client_credentials. Microsoft documents that the client secret must be URL-encoded when it is sent in a form-encoded request. If the client ID resolves but the supplied secret cannot validate for that client, token issuance stops with an invalid_client response such as AADSTS7000215. (OAuth 2.0 client credentials flow)
That position in the flow separates this error from several nearby failures:
- AADSTS700016 means the client application could not be found in the directory that received the request. Use the AADSTS700016 application-not-found guide.
- AADSTS7000218 means the request omitted both
client_assertionandclient_secret. - AADSTS7000222 means the provided client secret keys are expired.
- AADSTS65001 is a consent or permission-grant failure after the client and request have reached a different authorization boundary. Use the AADSTS65001 consent-required guide.
- AADSTS53003 is a Conditional Access block, not a secret-validation error.
Microsoft's central error reference gives each of those conditions a separate code. Read the full response from the failing request rather than treating every invalid_client message as the same incident. (Microsoft Entra authentication error reference)
Step 1: preserve evidence without preserving the secret
Before changing the app registration, capture:
- the complete error code and sanitized description;
- UTC timestamp, request ID, and correlation ID;
- Application (client) ID and token authority or endpoint;
- resource or scope requested;
- deployment environment, slot, region, release, and instance;
- secret-store name and version identifier, not the secret value;
- last known successful time and first known failure;
- recent application, secret-store, pipeline, or deployment changes;
- whether every instance fails or only one ring, region, or host.
Do not paste the client secret, access token, certificate private key, authorization code, or a complete client assertion into an incident, terminal transcript, log statement, or support ticket. If a secret was exposed during troubleshooting, treat that as a credential compromise and rotate it through the controlled procedure below.
The pattern of impact is immediately useful. If one deployment ring fails while another succeeds, Entra can validate at least one credential path; compare effective configuration and secret versions between rings. If every instance failed at the same moment, investigate expiration, credential deletion, a common secret-store reference, or a shared deployment change.
Step 2: prove the client ID and authority tenant
Do not rotate a credential for an application you have not positively identified. Compare the client ID in the failed request with the Application (client) ID on the intended app registration. Then prove that the {tenant} segment of the authority points to the directory that owns or accepts that client:
https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token
For a read-only inventory with Microsoft Graph PowerShell:
$clientId = "00000000-0000-0000-0000-000000000000"
Connect-MgGraph -Scopes "Application.Read.All"
$application = Get-MgApplication -Filter "appId eq '$clientId'"
$application | Select-Object Id, AppId, DisplayName, SignInAudience
$application.PasswordCredentials |
Select-Object DisplayName, KeyId, StartDateTime, EndDateTime
The output deliberately exposes credential metadata only. It cannot retrieve an existing secret value. Microsoft Entra displays that value only when the secret is created, and Microsoft Graph's addPassword operation likewise returns the generated secret only in its creation response. (use client secrets with Microsoft.Identity.Web, Microsoft Graph application addPassword)
Verify these identifiers separately:
AppIdis the public Application (client) ID used asclient_id.Idis the tenant-local application object ID used for directory administration.KeyIdis the credential's identifier—the portal's Secret ID—not the secret value.- The secret Value is the confidential string the workload presents. It is visible only at creation time.
If the application is not found, or it exists only in another directory, stop treating the incident as AADSTS7000215. Fix the client ID and authority pairing first. A perfectly copied secret from app A cannot authenticate app B, and a credential on the right application cannot compensate for a token request sent to the wrong tenant.
Step 3: distinguish the secret value from the Secret ID
This is the highest-yield check. In Microsoft Entra admin center > Entra ID > App registrations > your application > Certificates & secrets, a client-secret row includes metadata such as its description, expiration, and Secret ID. The Value appears only immediately after creation. Microsoft's client-secret documentation explicitly says to copy the value at creation because it cannot be retrieved later. (client-secret configuration)
The Secret ID is a GUID-shaped identifier. The Value is the actual confidential credential. They are not interchangeable. If the value was not captured into an approved secure store when the secret was created, there is nothing to reveal later; create a new credential through the controlled rotation process.
Compare the runtime reference with the credential metadata without revealing the secret:
- Does the secret-store entry name point to the intended application and environment?
- Does its version creation time match the portal credential's start time?
- Does the deployed configuration reference the current secret-store version or an older pinned version?
- Was a portal credential renamed while the application still resolves a different key name?
- Did a deployment variable receive the Secret ID because both fields were copied from the same page?
Do not ask an operator to read the value aloud or paste it into a comparison tool. Use version metadata, creation timestamps, a controlled deployment, and a token acquisition test to prove the mapping.
Step 4: inspect the effective runtime configuration
The value in source control is not necessarily the value the process uses. Trace the complete path:
app registration -> secure store -> deployment reference -> process configuration -> token request
Common breaks include:
- a deployment slot or namespace points to the development secret;
- an environment variable overrides the configured secure-store reference;
- a secret-store URI is correct but pins an old version;
- a container, function, or service was not restarted after configuration changed;
- a trailing newline entered the value during a file or command substitution;
- quotes became part of the stored value rather than configuration syntax;
- a platform truncated the value or interpreted special characters;
- a hand-built form request sent a raw secret where URL encoding was required;
- a pipeline updated one region but left another on the removed credential.
When the application uses MSAL or Microsoft.Identity.Web, prefer the library's credential configuration rather than manually constructing the token POST. Microsoft documents that Microsoft.Identity.Web can try multiple configured credentials in order, which supports a safe overlap during rotation. (Microsoft.Identity.Web client credentials)
If you maintain the HTTP request yourself, log only the presence and length of required fields—not their values—and compare the request construction with Microsoft's documented client-credentials parameters. The client_secret must be form encoded exactly once. Double encoding changes the value; failing to encode reserved characters can also change what the token endpoint receives.
Step 5: check expiration and credential state
Inspect StartDateTime and EndDateTime for every password credential on the intended application. Use UTC consistently. A newly created secret is not a repair if the workload still reads the old one, and an overlapping credential is not useful if its start time is in the future.
The Microsoft Entra error reference distinguishes AADSTS7000222 for expired secret keys, while Microsoft's confidential-client troubleshooting also tells operators investigating AADSTS7000215 to verify expiration. Check both the exact returned error and the credential dates rather than relying on a shortened exception message from a wrapper or vendor product. (authentication error reference, confidential-client troubleshooting)
For prevention, Microsoft Entra's Renew expiring application credentials recommendation identifies app-registration credentials approaching expiry within 30 days. That recommendation requires Microsoft Entra Workload ID for the documented experience; basic sign-in and audit logs remain available with Microsoft Entra ID Free, with longer built-in retention at P1/P2. (expiring-credential recommendation, activity-log access and licensing, Microsoft Entra data retention)
Step 6: rotate without creating avoidable downtime
Once you have identified the failed mapping, use an overlap rotation:
- Record the existing credential metadata, owners, application ID, dependent deployments, and approval reference.
- Create one replacement credential on the verified app registration. Copy its Value directly into the approved secure store; never put it in source control or a ticket.
- Update one nonproduction or canary instance to the new secret-store version.
- Acquire a token for the original tenant and resource through the application's normal library and path.
- Confirm a successful service-principal sign-in and application function.
- Roll the new reference through remaining instances and verify each ring.
- Monitor for requests that still use the old path during the overlap window.
- Remove the old credential only after every dependency has moved and the rollback window is closed.
- Confirm the removal in application-management audit logs and retest.
Microsoft's current client-secret guidance describes the same new-first, test, deploy, old-last sequence and supports multiple credentials during migration. Microsoft Graph provides explicit addPassword and removePassword operations when rotation is automated. (client-secret rotation strategy, manage Microsoft Entra applications with Graph)
Do not delete every existing secret as a cleanup step before the new credential is proven. That converts a partial outage into a guaranteed one and removes a safe rollback path. Conversely, do not leave emergency credentials indefinitely; unused credentials expand the application's attack surface.
Step 7: read service-principal and audit evidence
For an app-only token request, use Entra ID > Monitoring & health > Sign-in logs > Service principal sign-ins. Microsoft documents these as nonuser sign-ins where an application authenticates with a secret or certificate. Equivalent events can be grouped by service principal, status, IP address, and resource, so expand the row and match the exact timestamp. (service-principal sign-in logs)
Preserve:
- application and service-principal IDs;
- resource and resource-tenant IDs;
- status, error code, and failure reason;
- client credential type, when present;
- IP address, timestamp, request ID, and correlation ID;
- the successful event produced by the controlled retest.
Then inspect Audit logs with the ApplicationManagement category around the first failure. Credential additions and removals are security-relevant changes. Microsoft's application security-operations guidance specifically calls out credentials added to existing applications and identifies the application-management audit activity for certificate and secret updates. (security operations for applications)
Absence of a visible event in one portal view is not proof that the request never happened. Verify the directory, time range, log category, retention window, and role. Reports Reader is the documented least-privileged role for activity-log access; Security Administrator is required to configure diagnostic settings. (access Microsoft Entra activity logs)
Do not fix the wrong control plane
Several changes may make an incident look busy without addressing AADSTS7000215:
- Do not grant admin consent. Consent governs API authorization. It does not make an invalid client credential valid.
- Do not change API permissions. The token endpoint must authenticate the client before permissions can matter.
- Do not disable Conditional Access. A credential mismatch is not an AADSTS53003 policy result.
- Do not reset a user password or MFA method. Client credentials are app-only authentication; no user is presenting those factors.
- Do not switch to
/commonas a tenant workaround. Client-credential flows need the correct tenant context, and changing the authority can create a different failure. - Do not create a replacement app registration. A new registration has a new client ID, service principal relationships, permissions, policies, owners, and credentials.
- Do not expose the secret to prove it matches. A copied secret can become the next incident.
If token acquisition succeeds after the secret repair but the API returns 401 or 403, you have crossed into a different layer. Validate the access token's audience and app identity, then examine application permissions, admin consent, resource authorization, assignment, and workload Conditional Access separately.
Improve the credential design after recovery
Restoring service is not the end state if the same manual secret can fail again next quarter. Microsoft's application-registration security guidance recommends managed identity where possible, an external platform identity through federation for supported non-Azure workloads, and certificates when neither option fits. It explicitly advises against password credentials for production because they are easily mismanaged and compromised. (application registration security best practices)
Use this preference order:
- Managed identity for Azure-hosted workloads. Azure manages the underlying credential, so there is no secret value for an operator to copy or rotate.
- Workload identity federation for supported external platforms such as GitHub Actions, Kubernetes, and other OIDC-capable environments. The workload exchanges a trusted platform token instead of storing an Entra secret. (workload identity federation concepts)
- Certificate credential for a confidential client that can protect and rotate private key material appropriately.
- Client secret only when the safer patterns are not currently viable, with short, governed lifetime, secure storage, overlap rotation, ownership, and monitoring.
For a practical migration pattern, use the federated identity credentials guide. Keep the old and new credential methods overlapped until the federated path is proven, then remove the stored secret deliberately.
AADSTS7000215 administrator checklist
- Capture the exact error, UTC timestamp, request ID, correlation ID, client ID, tenant, resource, and failing deployment.
- Resolve the Application (client) ID to the intended app registration.
- Verify the authority tenant and cloud instance.
- Confirm the workload uses the secret Value, not the Secret ID or object ID.
- Trace the effective runtime configuration and secure-store version.
- Check start and end times, whitespace, truncation, quoting, and encoding.
- Compare a failing instance with a known working instance without exposing either secret.
- Create a replacement only on the verified application.
- Deploy and validate the new credential before removing the old one.
- Confirm the retest in service-principal sign-in logs.
- Preserve application-management audit evidence.
- Remove stale credentials after the rollout and rollback window.
- Plan managed identity, workload identity federation, or certificate migration.
Frequently asked questions
Can I recover the client secret value from Microsoft Entra?
No. Microsoft Entra displays a newly created secret value once. If it was not captured securely, create a replacement credential. The visible Secret ID is metadata and cannot authenticate the application.
Why does the secret work in one environment but not another?
Usually the environments use different client IDs, tenants, secret-store versions, deployment overrides, or request encoding. Compare the effective runtime chain rather than copying configuration files between environments.
Should I delete the old secret immediately after creating a new one?
No. Deploy the new value to a canary, confirm token acquisition and application function, move every dependency, then remove the old credential after the rollback window. Keep the overlap short and documented.
Does AADSTS7000215 mean the app lacks Microsoft Graph permission?
No. The error means client authentication failed. Permission or consent errors occur after Entra can identify and authenticate the client. Fix the credential first; investigate API authorization only if the next request reaches that layer.
The useful mental model is client ID, tenant, secret value, runtime path, encoding, credential dates, then evidence. Follow that chain and AADSTS7000215 becomes a bounded configuration incident rather than a reason to recreate the application. The safest repair restores one proven credential path, preserves rollback, and leaves the workload with fewer stored secrets than it had before.
About the author
MU.AMicrosoft 365 / Entra Engineer
MU.A is the editorial byline for Sentinel Identity, covering Microsoft Entra, Microsoft 365, and identity administration. Send corrections or questions through the contact page.
Feedback
Was this article helpful?
Anonymous — no account or comment required.
Related reading
Microsoft Entra Account Recovery: Deployment Guide
Deploy Microsoft Entra account recovery with Verified ID, Face Check, claim validation, staged testing, monitoring, troubleshooting, and safe rollback.
Microsoft 365 Cross-Tenant Calendar Sharing Migration
Migrate Microsoft 365 cross-tenant calendar sharing safely. Inventory OrgRel, map scopes, coordinate testing, preserve rollback, and verify both tenants.
AADSTS50034 User Account Not Found: Microsoft Entra Fix
Fix AADSTS50034 user account not found errors by verifying the sign-in name, target tenant, directory object, guest state, sync health, and Windows evidence.