azure - Microsoft Graph oauth2 错误 AADSTS900144 : the request body must contain the following parameter "grant type"

标签 azure azure-active-directory

继续收到此错误,我已获得正确的重定向 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/

相关文章:

python - 使用 Azure/Python 检索 unicode 数据中的表时出错

c# - 如何保护 Web API 和应用程序 (Azure AD) 使用的 Azure SQL 数据库的安全

azure - ADAL 身份验证无对话框提示

Azure AD - 获取用户的个人资料照片,OAUTH 访问失败

c# - 当前请求是否通过 Azure 部署通过 SSL 发出

azure - Azure 应用服务运行在哪个操作系统和 Web 服务器版本上?

azure - 访问 Azure Active Directory 中的 Key Vault 应用程序注册

azure - azure持久函数在调用事件时是否总是需要yield?

azure - 使用 Azure AD B2C 预注册用户

azure - 为存储帐户启用 Azure ADDS 身份验证时遇到问题