我使用MSAL (RPOC)和.net 4.6.1实现了Azure AD身份验证。如果用户的MFA未启用,我可以对用户进行身份验证。如果启用了它,则会收到一个错误。
**Microsoft.Identity.Client.MsalUiRequiredException: 'AADSTS50076: Due to a configuration change made by your administrator, or because you moved to a new location, you must use multi-factor authentication to access '00000003-0000-0000-c000-000000000000'.**这是我正在使用的代码。
public async Task<string> ValidateUserAsync()
{
string authority = string.Format("https://login.microsoftonline.com/{0}", tenant);
string[] scopes = new string[] { "User.Read" };
IPublicClientApplication app;
app = PublicClientApplicationBuilder.Create(clientId)
.WithAuthority(authority)
.Build();
var securePassword = new SecureString();
foreach (char c in password.ToCharArray())
securePassword.AppendChar(c);
var result = await app.AcquireTokenByUsernamePassword(scopes, username, securePassword).ExecuteAsync();
return result.IdToken;
}如何实现MFA?比如接收短信的代码和传递给这个?我将拥有自己的UI来接受代码。
发布于 2022-04-01 07:01:41
你不能。为了让用户进行MFA,他们必须在Microsoft登录页面上这样做。这是ROPC身份验证流的限制之一。我建议您使用不同的流,不要收集用户密码。
https://stackoverflow.com/questions/71685756
复制相似问题