0

I am trying to write my first Cron job that should request some info from Microsofts Graph Rest Api. I have done this succesfully with php, but I can't get it working with Bash curl. I have followed various syntax guides, and I am pretty sure my request is set up properly, however I am not able to get a proper response from Microsoft.

My Shell Script:

curl -i -X POST --data "{'grant_type':'client_credentials','client_secret':'****','client_id':'****','scope':'https://graph.microsoft.com/.default'}" --trace mylog.txt https://login.microsoftonline.com/****/oauth2/v2.0/token

I can see in my log file that the body is properly set, however I am always gretted by this error

{"error":"invalid_request","error_description":"AADSTS900144: The request body must contain the following parameter: 'grant_type'. Trace ID: 3a5fb023-6dcb-465c-a39a-2e432cc62c00 Correlation ID: 33387641-8a36-4dac-aa46-c623ce170960 Timestamp: 2020-09-03 10:01:42Z","error_codes":[900144],"timestamp":"2020-09-03 10:01:42Z","trace_id":"3a5fb023-6dcb-465c-a39a-2e432cc62c00","correlation_id":"33387641-8a36-4dac-aa46-c623ce170960","error_uri":"https://login.microsoftonline.com/error?code=900144"}

My log file https://pastebin.com/vFQARkyD

Maybe someone has a clue why this is happening.

1 Answer 1

0

You're using single quotes instead of double quotes in your JSON body.

Try:

curl -i -X POST --data '{"grant_type":"client_credentials","client_secret":"****","client_id":"****","scope":"https://graph.microsoft.com/.default"}' --trace mylog.txt https://login.microsoftonline.com/****/oauth2/v2.0/token

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .