Entra IDTroubleshooting

App sign-in errors in Microsoft Entra ID: AADSTS7000215, AADSTS700016, AADSTS50011 and more

What AADSTS7000215, 7000222, 700016, 50011, 700027 and 500011 mean, how to find the failing app in the sign-in logs, and how to fix the credential or setting and test it.

When a script, connector or web app can't get a token from Microsoft Entra ID, the error rarely reaches a user. It sits in a log file, a pipeline run or an API response, and the integration quietly stops working. In this post I'll go through six app-side AADSTS errors: what each one means, where to find the failed sign-in, and how to fix and test it.

Errors this guide fixes

  • AADSTS7000215: Invalid client secret provided.Token response / service principal sign-ins
  • AADSTS7000222: The provided client secret keys for app '...' are expired.Token response / service principal sign-ins
  • AADSTS700016: Application with identifier '...' was not found in the directory '...'.Sign-in page / token response
  • AADSTS50011: The redirect URI '...' specified in the request does not match the redirect URIs configured for the application '...'.Sign-in page
  • AADSTS700027: Client assertion failed signature validation.Token response / service principal sign-ins
  • AADSTS500011: The resource principal named ... was not found in the tenant named ...Sign-in page / token response
How this guide is organized: Symptoms → Why it happens → How to fix it → Verify the fix → Prevent it next timeFlow diagram of the article's sections in reading order: 1. Symptoms. 2. Why it happens. 3. How to fix it (6 steps: Find the failed sign-in; AADSTS7000215 and AADSTS7000222: replace the secret properly; AADSTS700016: confirm the app exists in the right tenant; AADSTS50011: register the exact redirect URI; AADSTS700027: fix the certificate credential; AADSTS500011: fix the resource). 4. Verify the fix. 5. Prevent it next time. Toolbox: AADSTS7000215, AADSTS700016, AADSTS50011, Get-MgServicePrincipal, Connect-MgGraph.1Symptoms2Why it happens3How to fix it4Verify the fix5Prevent it nexttime1Find the failedsign-in2AADSTS7000…and AADSTS7…3AADSTS7000…confirm the a…4AADSTS50011:register the e…5AADSTS7000…fix the certifi…6AADSTS5000…fix the resour…TOOLBOXAADSTS7000215AADSTS700016AADSTS50011Get-MgServicePrincipalConnect-MgGraphHow this guide is organized: Symptoms → Why it happens → How to fix it → Verify the fix → Prevent it next timeFlow diagram of the article's sections in reading order: 1. Symptoms. 2. Why it happens. 3. How to fix it (6 steps: Find the failed sign-in; AADSTS7000215 and AADSTS7000222: replace the secret properly; AADSTS700016: confirm the app exists in the right tenant; AADSTS50011: register the exact redirect URI; AADSTS700027: fix the certificate credential; AADSTS500011: fix the resource). 4. Verify the fix. 5. Prevent it next time. Toolbox: AADSTS7000215, AADSTS700016, AADSTS50011, Get-MgServicePrincipal, Connect-MgGraph.1Symptoms2Why it happens3How to fix it1Find the failed sign-in2AADSTS7000215 and AADSTS7000222: replacethe secret properly3AADSTS700016: confirm the app exists in theright tenant4AADSTS50011: register the exact redirect URI5AADSTS700027: fix the certificate credential6AADSTS500011: fix the resource4Verify the fix5Prevent it next timeTOOLBOXAADSTS7000215AADSTS700016AADSTS50011Get-MgServicePrincipalConnect-MgGraph
At a glance: how this guide is organized · 6 fix steps · 5 key tools

Symptoms#

A scheduled script, connector, pipeline or line-of-business web app fails to authenticate. Non-interactive apps get a JSON response from the token endpoint with error, error_description, error_codes and a correlation_id; interactive apps show the code on the sign-in page. The messages:

Text
AADSTS7000215: Invalid client secret provided. Ensure the secret being sent in the request is the client secret value, not the client secret ID, for a secret added to app '...'.
AADSTS7000222: The provided client secret keys for app '...' are expired.
AADSTS700016: Application with identifier '...' was not found in the directory '...'.
AADSTS50011: The redirect URI '...' specified in the request does not match the redirect URIs configured for the application '...'.
AADSTS700027: Client assertion failed signature validation.
AADSTS500011: The resource principal named ... was not found in the tenant named ...

Why it happens#

Which part of the token request failed, and how to fix itWhat does the error say didn't match? if The credential: Which code came back? if 7000215 or 7000222: Replace the secret properly (Copy the Value, not the Secret ID; update every place it's read.); if 700027: Upload the certificate it signs with (Then compare thumbprints with the client's store.); if App or resource: Which code came back? if 700016: Check the client ID and tenant (Application (client) ID, right tenant, and a service principal.); if 500011: Fix the scope or add the API (Check the App ID URI; the API needs a service principal.); if Redirect URI: Register the exact redirect URI (Scheme, host, port, path and trailing slash all count.)What does the error say didn'tmatch?Which code came back?FIXReplace thesecret properlyCopy the Value, notthe Secret ID; updateevery place it's read.7000215 or 7000222FIXUpload thecertificate itsigns withThen comparethumbprints with theclient's store.700027The credentialWhich code came back?FIXCheck the clientID and tenantApplication (client)ID, right tenant, and aservice principal.700016FIXFix the scope oradd the APICheck the App IDURI; the API needs aservice principal.500011App or resourceFIXRegister theexact redirectURIScheme, host, port,path and trailingslash all count.Redirect URIWhich part of the token request failed, and how to fix itWhat does the error say didn't match? if The credential: Which code came back? if 7000215 or 7000222: Replace the secret properly (Copy the Value, not the Secret ID; update every place it's read.); if 700027: Upload the certificate it signs with (Then compare thumbprints with the client's store.); if App or resource: Which code came back? if 700016: Check the client ID and tenant (Application (client) ID, right tenant, and a service principal.); if 500011: Fix the scope or add the API (Check the App ID URI; the API needs a service principal.); if Redirect URI: Register the exact redirect URI (Scheme, host, port, path and trailing slash all count.)What does the error say didn't match?The credentialWhich code came back?7000215 or 7000222FIXReplace the secret properlyCopy the Value, not the Secret ID; update everyplace it's read.700027FIXUpload the certificate it signs withThen compare thumbprints with the client's store.App or resourceWhich code came back?700016FIXCheck the client ID and tenantApplication (client) ID, right tenant, and a serviceprincipal.500011FIXFix the scope or add the APICheck the App ID URI; the API needs a serviceprincipal.Redirect URIFIXRegister the exact redirect URIScheme, host, port, path and trailing slash all count.
Figure 1 · Decision tree Which part of the token request failed, and how to fix it. Each code means one value in the token request didn't line up; start with what the error message names, then follow the code to the fix.

Every app has two objects. The app registration (application object) lives in its home tenant and holds the credentials and redirect URIs. The enterprise app (service principal) is the app's identity in each tenant where it's used. A token request names a tenant, a client ID, a credential and a resource, and each of these errors means one of them didn't line up.

CodeWhat didn't matchUsual causes
AADSTS7000215The secretThe Secret ID was copied instead of the Value, an old secret is still configured after a rotation, or the value was altered on the way (extra encoding, truncation).
AADSTS7000222Secret lifetimeThe secret the app sends has passed its expiry date.
AADSTS700016The client ID or tenantThe Object ID was used instead of the Application (client) ID, the request goes to the wrong tenant, the app was deleted, or a multitenant app has no service principal in this tenant yet. For SAML apps, the Identifier (Entity ID) doesn't match.
AADSTS50011The redirect URIThe URI the app sends isn't registered exactly: scheme, host, port, path and trailing slash all count.
AADSTS700027The certificateThe public key isn't uploaded, the certificate was renewed on the client but not in Entra ID, or the app signs with a different certificate.
AADSTS500011The resource (API)A typo in the scope or App ID URI, an API whose multitenant app hasn't been added to this tenant, or the wrong tenant.

How to fix it#

1. Find the failed sign-in#

In the Microsoft Entra admin center, go to Entra ID › Monitoring & health › Sign-in logs. App-only sign-ins are on the Service principal sign-ins tab; apps that sign users in appear under the user sign-in tabs. Filter by the application ID and status Failure, or search for the correlation ID from the error. The details show the error code, failure reason, resource and client credential type. If the app doesn't exist in the tenant (700016), there may be no service principal entry, so use the correlation ID and the timestamp instead.

2. AADSTS7000215 and AADSTS7000222: replace the secret properly#

  1. Open Entra ID › App registrations, select the app and open Certificates & secrets › Client secrets. Check the expiry dates.
  2. Select New client secret and copy the Value straight away; it's only shown once. The Secret ID column is an identifier, not the secret.
  3. Update every place the app reads the secret from: its configuration, the vault, pipeline variables, or a local override left over from development.
  4. Delete the old secret only after the new one works.
PowerShell
Connect-MgGraph -Scopes "Application.Read.All"
$app = Get-MgApplication -Filter "appId eq '11111111-2222-3333-4444-555555555555'"
$app.PasswordCredentials | Select-Object DisplayName, KeyId, EndDateTime
$app.KeyCredentials | Select-Object DisplayName, KeyId, EndDateTime

3. AADSTS700016: confirm the app exists in the right tenant#

  • Compare the client ID in the request with Application (client) ID on the app's Overview page.
  • Check the tenant in the authority URL (login.microsoftonline.com/<tenant>/). A single-tenant app only exists in its home tenant.
  • Check for a service principal: Get-MgServicePrincipal -Filter "appId eq '...'". If a third-party or multitenant app has none, an admin needs to add it by granting consent (see AADSTS65001 and AADSTS90094 consent errors).
  • For SAML apps, compare the issuer the app sends with Identifier (Entity ID) under Entra ID › Enterprise apps › app › Single sign-on › Basic SAML Configuration.

4. AADSTS50011: register the exact redirect URI#

Copy the redirect URI and app ID from the error. Open the app registration, select Authentication, add the URI to the platform configuration the app uses, save, and allow a few minutes before retrying. If the URI in the request is wrong, for example http:// from an app behind a TLS-offloading proxy, fix the app's configuration instead of registering a bad URI. For SAML apps, the value to check is the Reply URL in Basic SAML Configuration.

5. AADSTS700027: fix the certificate credential#

Under Certificates & secrets › Certificates, upload the public key (.cer, .pem or .crt) of the certificate the app actually signs with, then compare thumbprints with the client's store:

PowerShell
Get-ChildItem Cert:\LocalMachine\My, Cert:\CurrentUser\My |
    Select-Object Subject, Thumbprint, NotAfter

6. AADSTS500011: fix the resource#

Check the scope or resource value the app requests, such as https://graph.microsoft.com/.default or a custom API's App ID URI. Confirm the API has a service principal in the tenant with Get-MgServicePrincipal -Filter "appId eq '...'" using the API's app ID. For a partner's multitenant API, add and consent to the API first.

Verify the fix#

For app-only access, request a token directly. A good result returns token_type Bearer and an expires_in value, and a Success entry appears on the Service principal sign-ins tab. Don't print or store the token itself.

PowerShell
$tenantId = "contoso.onmicrosoft.com"
$body = @{
    client_id     = "11111111-2222-3333-4444-555555555555"
    client_secret = $secretValue   # read from your vault, never hard-coded
    scope         = "https://graph.microsoft.com/.default"
    grant_type    = "client_credentials"
}
$response = Invoke-RestMethod -Method Post -Body $body `
    -Uri "https://login.microsoftonline.com/$tenantId/oauth2/v2.0/token"
$response.token_type; $response.expires_in

For certificate-based apps, Connect-MgGraph -ClientId ... -TenantId ... -CertificateThumbprint ... is a quick test. For interactive apps, sign in once and confirm the user sign-in entry for the app shows Success.

Prevent it next time#

References#

Written and checked against current Microsoft Learn documentation. Test changes with a pilot group before rolling them out to everyone, and if an admin center path has moved since, search for the setting name instead.

Spotted a mistake, or did this fix work differently for you? Email me or message me on LinkedIn — corrections are credited in the article.

Written by

Omer Eltayeb

M365 Subject Matter Expert, former Microsoft Cloud Solutions Architect, Microsoft Certified Trainer and Microsoft Innovative Educator Expert (2024–26) and Microsoft Elevate Educator Expert (2026–27). I share practical, step-by-step guides, study plans, scripts and toolkits for Microsoft Intune, Configuration Manager, Microsoft Entra ID, Microsoft Defender, Exchange and Microsoft 365 with the community.

Microsoft Certified Trainer (MCT) 2026Microsoft Innovative Educator Expert 2025–2026Microsoft Elevate Educator Expert 2026–2027ISC2 Certified Information Systems Security Professional (CISSP)Microsoft 365 Certified: Enterprise Administrator Expert (MS-102)