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'
这是命令。
How about this 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.
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'")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.