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?
Use UserPasswordCredential
class instead which is a subclass of UserCredential
Try UserPasswordCredential
, the class had to be renamed in v3.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With