为什么通过“ acquire_token_with_username_password”获取Azure AD令牌失败?

时间:2020-04-19 06:17:05

标签: python python-3.x azure-active-directory

当我尝试进行身份验证并使用“ acquire_token_with_username_password”方法从Azure AD获取令牌时,出现以下错误:

请求正文必须包含以下参数:“ client_assertion”或“ client_secret”。

我正在传递客户端ID。我在其他一些帖子中读到,问题可能是该应用程序应该注册为“本地”应用程序而不是Web应用程序,但是该发布是2年前的,我没有在Azure的应用程序属性中看不到任何地方来指定它是本机应用程序。我通过调用在变量中传递ID:

 token = auth_context.acquire_token_with_username_password(resource, username, password, clientId)

我在“ acquire_token_with_username_password”中看不到要传递client_assertion或client_secret的任何地方,更不用说我不确定要放在哪里。

1 个答案:

答案 0 :(得分:1)

是的,如果AD App是chdir()类型,则需要'client_assertion'或'client_secret',只需按照屏幕快照将AD App设置为公共客户端(即本机应用),即可使用

enter image description here

相关问题