继续收到此错误,我已获得正确的重定向 URI、clientId、clientSecret、grant_type 和范围。我尝试过在正文中作为表单数据作为 url 查询参数,但我不断收到完全相同的错误。我已经得到了正确的代码,我尝试刷新它,但无济于事。基本网址为https://login.microsoftonline.com/common/oauth2/v2.0/token .
res = wrapped_post(
MS_BASE,
headers={"Content-Type": "application/x-www-form-urlencoded"},
params = {
"redirect_uri": "http://localhost/",
"client_id": clientId,
"scope": "Files.ReadWrite offline_access",
},
payload={
"redirect_uri": "http://localhost/",
"client_id": clientId,
"scope": "Files.ReadWrite offline_access",
"grant_type": "authorization_code",
"code": code,
"client_secret": client_secret
},
)
这是一个示例请求。我尝试过使用 files= 而不是有效负载(用于表单数据),没有任何查询参数,而是使用所有查询参数等。 wrapped_post
只是一个用于包装 requests.post 函数的函数,具有相同的 kwargs(我认为是有效负载而不是主体)。
最佳答案
grant_type=code 需要在参数中
关于azure - Microsoft Graph oauth2 错误 AADSTS900144 : the request body must contain the following parameter "grant type",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71570553/