Exception of type 'Microsoft.Identity.Client.MsalClientException' was thrown: password_required_for_managed_user
MikeMalter-Personal opened this issue · 1 comments
Which platform has the issue? =>net45
What authentication flow has the issue? Username Password
Is this a new or existing app? This is a new app or experiment
Code: In this code the clientId and tenandID come from the manage applications pane in Azure Active Directory.
string clientId = "************************************";
string tenantID = "************************************";
List<string> scopes = new List<string> { "User.ReadBasic.All" };
IPublicClientApplication publicClientApplication = PublicClientApplicationBuilder
.Create(clientId)
.WithTenantId(tenantID)
.Build();
UsernamePasswordProvider authProvider = new UsernamePasswordProvider(publicClientApplication, scopes);
GraphServiceClient graphClient = new GraphServiceClient( "https://login.microsoftonline.com/common/oauth2/nativeclient", authProvider, null);
var users = await graphClient.Users
.Request()
.Select("displayName")
.GetAsync();
Expected behavior => get a list of users on my O365 tenant.
Actual behavior => exception was thrown, drilling down into the InnerExceptions I get this error: password_required_for_managed_user
Firstly, this is the ADAL repo, but the code you have is MSAL - the repo is here: https://github.com/AzureAD/microsoft-authentication-library-for-dotnet.
Secondly, since you are using the Graph SDK please log issues on them first, since most of the code is on their side.
But anyway, Username / Password is strongly discouraged, but in this case you might not be passing in a password?