AcquireTokenAsync为图形客户端库中的用户凭证返回401(未经授权)

问题描述 投票:0回答:1

我的代码段:

AuthenticationContext authenticationContext = new AuthenticationContext(aadTokenIssuerUri);

UserCredential userCredentials = new UserPasswordCredential(username, password);

AuthenticationResult authenticationResult = authenticationContext.AcquireTokenAsync(
                resources,
                clientId,
                userCredentials)
                .GetAwaiter().GetResult();

此函数总是返回“请求正文必须包含以下参数:'client_assertion'或'client_secret'”和“响应状态代码不表示成功:401(未授权)”。我正在尝试验证Azure AD用户。

c# azure azure-active-directory adal
1个回答
0
投票

转到在aad中注册的应用程序,然后单击[C0 Authentication,将应用程序作为公共客户端]设置为>。这应该可以阻止Azure要求客户端密钥或客户端断言。

Advanced settings

此后,清单中的enter image description here将为allowPublicClient

© www.soinside.com 2019 - 2024. All rights reserved.