Error Details
| Fact | Value | Source | Note |
|---|
| Exact error string | AADSTS700016: Application not found in tenant directory | Entra ID logs | -> Indicates the app is missing or tenant mismatch. |
| OS build range | Windows 11 23H2 | System Information | -> Affected OS version. |
| Registry key involved | HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\OAuth2 | Registry Editor | -> Contains OAuth2 configuration details. |
| Relevant service URL | https://login.microsoftonline.com | Network logs | -> Entra ID authentication endpoint. |
| Log line signature | oauth2_sign_in_error_AADSTS700016 | Windows Event Viewer | -> Identifies the error in system logs. |
Log Files to Check
C:\Windows\System32\winevt\Logs\Microsoft-Windows-Authentication.evtxC:\ProgramData\EntraID\logs\auth_logs.log
What This Error Actually Means
The error
AADSTS700016: Application not found in tenant directory is raised by Microsoft Entra ID (formerly Azure AD) during OAuth2 authentication flows when the requesting application’s client ID is not registered in the target tenant directory. This error specifically indicates a mismatch between the application identifier used in the authentication request and the applications registered in the tenant’s Entra ID directory. The error is generated by the Entra ID authentication pipeline, which validates the
client_id parameter against its internal catalog of registered applications. The hexadecimal code
0x80044010 (not directly visible in logs) maps to this error in internal systems, but the public-facing identifier is
AADSTS700016. This error commonly occurs during SSO flows, API access, or device enrollment scenarios where the application manifest or tenant context is misconfigured.
---
Affected Versions and Scope
This error is observed in **Windows 11 23H2** (OS build 22000.2189 or later) when integrating with Microsoft Entra ID. It affects tenants where:
- The application is not registered in the target tenant (e.g., a multi-tenant app is not properly consented).
- The device or user is attempting to authenticate to a tenant other than the one where the app is registered (tenant mismatch).
- The OAuth2 client ID in the application’s configuration does not match the Entra ID app registration.
**Not affected** are older OS builds (e.g., Windows 10 21H2) unless the same misconfigurations exist. Additionally, tenants using legacy authentication protocols (e.g., ADAL) are less likely to encounter this error, as modern OAuth2 flows enforce stricter validation.
---
Where To Look First: Logs and Event IDs
1. **Windows Event Viewer**:
- Log path:
C:\Windows\System32\winevt\Logs\Microsoft-Windows-Authentication.evtx
- Search for
Event ID 634 (OAuth2 sign-in failure) and
Event ID 4625 (failed login attempt).
- Look for the signature
oauth2_sign_in_error_AADSTS700016 in the event description.
2. **Entra ID Logs**:
- Log file:
C:\ProgramData\EntraID\logs\auth_logs.log
- Grep for the exact string:
"AADSTS700016: Application not found in tenant directory".
3. **Registry Key**:
- Check
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\OAuth2 for misconfigured tenant IDs or client secrets.
---
Root Causes
1. Missing Application Registration
The application’s client ID is not registered in the target tenant. Verify in the **Entra ID portal > App registrations**.
2. Tenant Mismatch
The device or user is attempting to authenticate to a different tenant than where the app is registered. Confirm the
tenant_id in the registry key
HKEY_LOCAL_MACHINE\...\OAuth2 matches the target tenant.
3. Corrupted OAuth2 Configuration
The local OAuth2 cache contains outdated or incorrect client secrets or redirect URIs. This can occur after app re-registration or tenant migration.
---
Fix Procedure
- **Verify App Registration in Entra ID**:
Get-MgApplication -Filter "appId eq 'YOUR_CLIENT_ID'"
If the app is missing, register it in the **Entra admin center > App registrations > New registration**.
- **Correct Tenant ID in Registry**:
Modifying this registry key can break enrolled devices if incorrect.
Update HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\OAuth2 with the correct tenant_id using:
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\OAuth2" -Name "TenantId" -Value "CORRECT_TENANT_ID"
- **Update Intune Device Configuration**:
In the **Intune admin center > Devices > Configuration profiles > Create profile**, use the OMA-URI:
./Device/Vendor/MSFT/EntraID/TenantId
Set the value to the correct tenant ID.
- **Clear OAuth2 Cache**:
Invoke-Command -ScriptBlock { Remove-Item -Path "C:\ProgramData\Microsoft\Windows\OAuth2\Cache\*" -Recurse -Force }
---
Error Code Variants
| Error Code | Description | Distinguishing Factor |
AADSTS700016 | App not found in tenant | Client ID mismatch or missing registration |
AADSTS50011 | Invalid redirect URI | Redirect URI in app registration does not match request |
AADSTS700021 | Invalid client secret | Expired or incorrect client secret in OAuth2 request |
---
Verification
After applying fixes:
1. Check
C:\ProgramData\EntraID\logs\auth_logs.log for absence of
AADSTS700016 and presence of successful sign-in entries.
2. In the **Entra admin center > Audit logs**, verify that the app appears in the "Resource" column for successful authentication events.
3. Run
Get-WinEvent -LogName "Microsoft-Windows-Authentication/Admin" | Where-Object { $_.Id -eq 634 } to confirm no further failures.
---
Prevention
1. **Baseline Policy in Intune**:
Create a device configuration profile in **Intune admin center > Devices > Configuration profiles > Create profile** with the OMA-URI
./Device/Vendor/MSFT/EntraID/TenantId to enforce correct tenant IDs.
2. **Automated Validation Script**:
Deploy a PowerShell script via device compliance policies to validate app registrations:
Get-MgApplication -Filter "appId eq '$env:CLIENT_ID'" | Select-Object AppId, DisplayName, TenantId
3. **Registry Lockdown**:
Use Group Policy to restrict write access to
HKEY_LOCAL_MACHINE\...\OAuth2 and prevent unauthorized modifications.
Use dsregcmd /status to quickly check device registration status and tenant alignment without parsing logs.