Does Microsoft.IdentityModel.Clients.ActiveDirectory.UserCredential not accept 2 parameters?

I am using ADAL in my code. One thing I want to use is to use different credentials, so I can allow other users to use Azure AD in the console program.

Microsoft.IdentityModel.Clients.ActiveDirectory.UserCredential cred = new Microsoft.IdentityModel.Clients.ActiveDirectory.UserCredential("username", "password");

This is the line that I use to create user credentials. I am using nuget to get the latest ADAL. However, this line displays an error:

The best overloaded method match for "Microsoft.IdentityModel.Clients.ActiveDirectory.UserCredential.UserCredential (string, Microsoft.IdentityModel.Clients.ActiveDirectory.UserAuthType)" contains some invalid arguments

However, according to https://msdn.microsoft.com/en-us/library/microsoft.identitymodel.clients.activedirectory.usercredential.aspx

UserCredential(String, String)
Constructor to create credential with client id and secret 

Does anyone know what I did wrong?

thank

+4
source share
1 answer

In ADAL.NET v3 UserCredential Constructor is no longer supporting the second parameter ( password), instead you need to use UserPasswordCredentialclass

Example

var credentials = new UserPasswordCredential(userName, password);
var context = new AuthenticationContext(authorityUri);
var authResult = context.AcquireTokenAsync(resource, clientId, credentials).Result;
+16
source

All Articles