Error Details
| Fact | Value | Source | Note |
|---|
| Exact error string | AADSTS7000218 | Azure AD sign-in logs | -> Authentication failure |
| Application ID | <app_id> | Microsoft Entra admin center | |
| Registry path for MSAL token cache on Windows | HKCU:\SOFTWARE\Microsoft\MSAL.PS\<app_id>\TokenCache | Windows registry | -> Cache location |
| Relevant service/endpoint URL | https://login.microsoftonline.com/<tenant>/oauth2/v2.0/token | Azure AD endpoint | |
| Log line signature | AADSTS7000218: The request body must contain the following parameter: | MSAL log file | -> Error pattern |
Log Files to Check
%TEMP%\msal.logAzure AD sign-in logs
What This Error Actually Means
The error code AADSTS7000218 is raised by Microsoft Entra ID (formerly Azure Active Directory) when an application attempts to authenticate using a public client flow but the application registration in Entra ID requires confidential client authentication. The component that raises this error is the OAuth 2.0 token endpoint, which enforces strict validation of request parameters based on the type of client making the request. Public clients are expected to use flows like authorization_code or device_code without including a client secret or assertion, whereas confidential clients must provide such credentials.
This error signifies a mismatch between how an application is configured and how it attempts to authenticate with Entra ID. It indicates that either the application's registration in Entra ID has been updated to require a client secret but the application code still uses public client flows without providing one, or vice versa.
Affected Versions and Scope
This error affects Microsoft 365 tenants using Entra ID for authentication. It is particularly relevant when applications are being migrated from older configurations where they were allowed to use public client flows without secrets to newer configurations that enforce the use of confidential clients with secrets or certificates.
The error does not affect scenarios where:
- The application registration explicitly allows public client flows.
- The application uses a confidential client flow and correctly includes a client secret in its authentication requests.
- The application is configured as a public client but does not attempt to authenticate using flows that require a client secret (e.g., it only uses implicit grant type).
Where To Look First: Logs and Event IDs
To diagnose this issue, you should first check the following logs:
Azure AD sign-in logs: Navigate to Microsoft Entra admin center > Monitoring & health > Sign-in logs. Filter by Application ID and look for entries with error code AADSTS7000218.
MSAL log file: The MSAL library used in many applications will log detailed information about token requests, including errors like AADSTS7000218. This can be found at %TEMP%\msal.log.
Windows registry path for MSAL token cache: On Windows systems, the MSAL library stores cached tokens in the registry under HKCU:\SOFTWARE\Microsoft\MSAL.PS\\TokenCache. Reviewing this can provide insights into recent authentication attempts.
The exact log line to grep for is:
AADSTS7000218: The request body must contain the following parameter:
Event IDs related to this issue include
4625 and
4723, which are logged in the Security event log on Windows systems when authentication attempts fail due to missing or incorrect parameters.
Root Causes
Application Registration Configuration Mismatch
This occurs when an application is registered as a public client but Entra ID requires it to use confidential client flows. This can happen if the 'Allow public client flows' toggle in Microsoft Entra admin center has been disabled for the app, or if the app manifest incorrectly specifies that public client flows are not allowed.
Incorrect MSAL Configuration
Applications using the MSAL library may be misconfigured to use PublicClientApplicationBuilder instead of ConfidentialClientApplicationBuilder. This can lead to authentication failures when confidential client credentials (client_secret) are required but not provided.
Expired or Missing Client Secret
If an application is configured as a confidential client, it must provide a valid and non-expired client secret in its token requests. If the secret has expired or was never set up correctly, this error will occur.
Fix Procedure
- Check Application Registration Settings:
- Navigate to Microsoft Entra admin center > App registrations > > Authentication.
- In Advanced settings, ensure that 'Allow public client flows' is set to Yes if the application should use public client flows without a secret. If it needs confidential client authentication, this setting must be No.
- Review App Manifest:
- Navigate to Microsoft Entra admin center > App registrations > > Manifest.
- Ensure that the 'allowPublicClient' property is set to true for public client applications. For confidential clients, this should be false or omitted.
- Create Client Secret (for Confidential Clients):
- Navigate to Microsoft Entra admin center > App registrations > > Certificates & secrets.
- Click 'New client secret' and create a new secret. Copy the value immediately as it will not be shown again.
- Store this secret securely, such as in Azure Key Vault or an environment variable.
- Update Application Configuration:
- Ensure that your application's configuration includes the client_secret parameter when making OAuth2 token requests for confidential clients. For public clients, ensure no secret is included and use appropriate grant types like authorization_code or device_code.
Important: Changing application registration settings can affect existing users and devices. Ensure you communicate any changes to affected parties before making updates.
Get-MgApplication -ApplicationId | Select-Object -ExpandProperty PasswordCredentials | Select-Object DisplayName,EndDateTime: Use this PowerShell cmdlet to check the expiry date of client secrets and ensure they are valid.
Error Code Variants
| Code | Description |
| AADSTS700016: The request body must contain the following parameter: 'grant_type' | This error occurs when a required OAuth2 grant type is missing from the token request. |
| AADSTS700089: The client assertion or secret is invalid | Indicates that a provided client_secret or client_assertion is either incorrect, expired, or not recognized by Entra ID. |
| AADSTS700114: The request body must contain the following parameter: 'client_id' | This error occurs when the application's client identifier (client_id) is missing from the token request. |
Verification
To verify that the fix has been applied correctly:
- Check Azure AD sign-in logs for successful authentication attempts without AADSTS7000218 errors.
- Review MSAL log files and ensure there are no more instances of
AADSTS7000218.
- Use the following PowerShell cmdlet to confirm that the application's token requests now include the correct parameters:
Invoke-MgGraphRequest -Method GET -Uri "https://graph.microsoft.com/v1.0/deviceManagement/managedDevices"
Prevention
To prevent recurrence of this issue, ensure that all application registrations in Entra ID are correctly configured to match the intended authentication flow (public vs confidential client). Implement a baseline policy requiring regular reviews and updates of application configurations. Additionally, use Azure Key Vault or similar secure storage solutions for managing client secrets, reducing the risk of exposure.
Tips: Use PowerShell cmdlets like Get-MgApplication to automate checks on application registrations and ensure compliance with security policies.
By following these steps and maintaining a proactive approach to application registration management in Entra ID, you can effectively mitigate the occurrence of AADSTS7000218 errors and improve overall system stability.