ADAL.NET v3 does not support AcquireToken with UserCredential?

cuongle picture cuongle · May 26, 2016 · Viewed 10.4k times · Source

In ADAL.NET 2.x, we use the below code to acquire token from Azure AD using UserCredential and it works perfectly:

 var authContext = new AuthenticationContext(Authority);
 var userCredential = new UserCredential(username, password);
 var token = authContext.AcquireToken(ResourceUrl, ClientId, userCredential);

When I upgraded ADAL.NET v3 today, the code cannot be compiled anymore because on the new version, UserCredential does not have overloaded constructor with username and password.

How I can workaround this with the new version of ADAL.NET v3?

Answer

Kanishk Panwar picture Kanishk Panwar · May 26, 2016

Use UserPasswordCredential class instead which is a subclass of UserCredential