Entra ID token request fails: the request body must contain the parameter 'grant_type'
AADSTS90014: The request body must contain the following parameter: 'grant_type'.Short answer
The token endpoint did not find grant_type in the form body of your POST. Send application/x-www-form-urlencoded data in the body, not JSON and not the query string. For client credentials the body needs client_id, client_secret, scope ending in /.default, and grant_type=client_credentials.
Fix it fast
1Find out which cause you have
Send the request with curl and form fields. If it works, the fault is in how your client builds the body.
curl -s -X POST "https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/token" \ -H "Content-Type: application/x-www-form-urlencoded" \ --data-urlencode "client_id=<application-id>" \ --data-urlencode "client_secret=<secret>" \ --data-urlencode "scope=https://graph.microsoft.com/.default" \ --data-urlencode "grant_type=client_credentials"2Match what you see, then jump to its fix
- 1
The request has Content-Type: application/json, or the fields appear after a ? in the URL, and the body is emptyThe body is JSON or the parameters are in the URLFix - 2
The body is form-encoded, but the message names a parameter such as grant_type, and your code does not set it or sets it under another namegrant_type or another required field is missing or misspelledFix - 3
The URL is a /authorize URL, a tenant that does not exist, or a path other than /oauth2/v2.0/tokenThe request goes to the wrong URL, so the endpoint does not read your body as a token requestFix
- 1
What does the error look like?
AADSTS90014: The request body must contain the following parameter: 'grant_type'.AADSTS900144: The request body must contain the following parameter: 'grant_type'.
Cause 1 of 3
The body is JSON or the parameters are in the URL
1Check
Microsoft documents the token request as a POST with Content-Type application/x-www-form-urlencoded and the parameters in the body. Anything else leaves the body without grant_type.
# Look at the raw request in your HTTP client's log or a proxy: header Content-Type and the body2Fix
Build the body with a form encoder. In Node.js use URLSearchParams, which fetch sends as form data.
const body = new URLSearchParams({
client_id: process.env.CLIENT_ID,
client_secret: process.env.CLIENT_SECRET,
scope: "https://graph.microsoft.com/.default",
grant_type: "client_credentials",
});
const res = await fetch(`https://login.microsoftonline.com/${process.env.TENANT_ID}/oauth2/v2.0/token`, {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body,
});3Verify
The response is 200 with access_token, token_type Bearer and expires_in.
# console.log((await res.json()).token_type)Confirmed by learn.microsoft.com
Cause 2 of 3
grant_type or another required field is missing or misspelled
1Check
The client-credentials request needs client_id, scope, client_secret (or a client assertion) and grant_type set to client_credentials. The error text names the field the endpoint did not find.
# Print the keys of the body you send (not the secret values)2Fix
Add the missing field with the exact name. For a shared secret all four must be present.
grant_type=client_credentials
client_id=<application-id>
client_secret=<secret>
scope=https://graph.microsoft.com/.default3Verify
The same request returns an access token.
# Decode the token on a debugging tool you control, or call the API with itConfirmed by learn.microsoft.com
Cause 3 of 3
The request goes to the wrong URL, so the endpoint does not read your body as a token request
1Check
The token endpoint is https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token and takes POST. Compare it with the token_endpoint in the discovery document.
curl -s https://login.microsoftonline.com/<tenant-id>/v2.0/.well-known/openid-configuration | grep -o '"token_endpoint":"[^"]*"'2Fix
Use the exact token_endpoint from the discovery document and the POST method.
POST https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/token3Verify
Repeat the request from the first step against that URL.
# Expect HTTP 200 and JSON with access_tokenConfirmed by learn.microsoft.com
How do I stop it coming back?
- Use MSAL where you can; it builds token requests for you.
- Keep one tested curl command in the repository as a reference for the exact request.
- Log the Content-Type and field names of auth requests (never the secret) in non-production.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Security
A valid JWT fails to decode because its segments are base64url, not base64
Convert.FromBase64String throws FormatException on a JWT segment
A JWT is three base64url segments joined by dots, and a standard base64 decoder refuses all three differences: base64url uses - and _ instead of + and /, leaves off the = padding, and the dots are not part of any base64 alphabet.
3 causes, each with a fixSecurity
jsonwebtoken rejects a token: invalid signature, jwt expired or jwt malformed
JsonWebTokenError: invalid signature
Each message points at a different step.
5 causes, each with a fixSecurity
Node.js HTTPS call fails with UNABLE_TO_VERIFY_LEAF_SIGNATURE
code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'
Node.js could not build a trusted chain from the server's certificate to a root it knows.
3 causes, each with a fixSecurity
Angular HttpClient does not add the X-XSRF-TOKEN header to a request
403 Forbidden on POST, PUT or DELETE while GET works
Angular copies the XSRF-TOKEN cookie into an X-XSRF-TOKEN header only for mutating requests to the same origin, and only when the cookie is readable by script.
5 causes, each with a fixSecurity
An [Authorize] endpoint rejects a request with a bearer token
Authorization Header sent: no Bearer token sent.
An [Authorize] endpoint without a policy name requires an authenticated user.
4 causes, each with a fixSecurity
ASP.NET Core API rejects an Angular user's token: the signature key was not found
401 Unauthorized
The API looked for the key named by the token's kid in the key set it downloaded from your Authority, and the key was not there.
4 causes, each with a fix