Same issue. My curl:
curl -X POST \
'https://login.microsoftonline.com/<TenantID>/oauth2/v2.0/token' \
--header 'Accept: */*' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Content-Length: 0' \
--data-urlencode 'client_id=<ClientID>' \
--data-urlencode 'redirect_uri=<MyRedirectURi>' \
--data-urlencode 'grant_type=authorization_code' \
--data-urlencode 'client_secret=<MyClientSecret>' \
--data-urlencode 'code=<MyCode>'
Is taken from : https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow
All values inside <> are get from Azure and I'm 100% sure that are correct. <MyCode> is taken from request for code.
Curl is exec on Apache Server. And res is:
{
"error": "invalid_request",
"error_description": "AADSTS900144: The request body must contain the following parameter: 'grant_type'.\r\nTrace ID: e14bd767-2062-4175-8e89-839c9bc81900\r\nCorrelation ID: ee07635e-bd30-4049-b0b9-75cabcf8103e\r\nTimestamp: 2022-06-22 12:36:07Z",
"error_codes": [
900144
],
"timestamp": "2022-06-22 12:36:07Z",
"trace_id": "e14bd767-2062-4175-8e89-839c9bc81900",
"correlation_id": "ee07635e-bd30-4049-b0b9-75cabcf8103e",
"error_uri": "https://login.microsoftonline.com/error?code=900144"
}