【发布时间】:2018-12-02 06:10:03
【问题描述】:
我在使用 Python 为 Microsoft Graph API 接收不记名令牌时遇到问题。这是我目前所拥有的:
import requests
import json
headers = {
'Content-Type': 'x-www-form-urlencoded',
'Authorization': 'Basic'
}
data = {
"grant_type": "client_credentials",
"client_id" :"<client_id>",
"client_secret": "<client_secret>",
"resource": "https://graph.microsoft.com"
}
r = requests.post('<token_address>', headers=headers, data=data)
print(r.text)
我通过 x-www-form-urlencoded 在 Postman 中工作,但似乎无法在 Python 中工作。它返回请求正文必须包含以下参数:'grant_type'。我意识到问题可能与需要转换的数据有关,但我不确定从哪里开始。
【问题讨论】:
标签: python oauth-2.0 python-requests microsoft-graph-api