2
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d 'client_id=535fb089-9ff3-47b6-9bfb-4f1264799865&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default&client_secret=qWgdYAmab0YSkuL1qKv5bPX&grant_type=client_credentials' 'https://login.microsoftonline.com/common/oauth2/v2.0/token'

Here is the command.

2 Answers 2

3

How about this sample script?

Sample script :

import json
import requests

url = "https://login.microsoftonline.com/common/oauth2/v2.0/token"
payload = {
    "client_id": "535fb089-9ff3-47b6-9bfb-4f1264799865",
    "client_secret": "qWgdYAmab0YSkuL1qKv5bPX",
    "grant_type": "client_credentials",
    "scope": "https://graph.microsoft.com/.default"
}
headers = {
    "Content-Type": "application/x-www-form-urlencoded"
}
res = requests.post(url, headers=headers, data=json.dumps(payload))
print(res.text)

If I misunderstand your question, I'm sorry.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks, it looks like that worked for the most part. Now I'm just getting a weird error. "error":"invalid_request","error_description":"AADSTS90014: The request body must contain the following parameter: 'grant_type'.
@mickolasjae I'm sorry for the inconvenience. As a modification point, please modify from res = requests.post(url, headers=headers, data=json.dumps(payload)) to res = requests.post(url, headers=headers, data=payload), and try again.
@mickolasjae If you have problems for my answer yet, feel free to tell me. I would like to study to solve your problems.
1

You could use os (though it's outdated)

import os 
os.system("curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d 'client_id=535fb089-9ff3-47b6-9bfb-4f1264799865&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default&client_secret=qWgdYAmab0YSkuL1qKv5bPX&grant_type=client_credentials' 'https://login.microsoftonline.com/common/oauth2/v2.0/token'")

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.