Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ADAL.NET v3 does not support AcquireToken with UserCredential?

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?

like image 714
cuongle Avatar asked May 26 '16 16:05

cuongle


2 Answers

Use UserPasswordCredential class instead which is a subclass of UserCredential

like image 179
Kanishk Panwar Avatar answered Nov 06 '22 22:11

Kanishk Panwar


Try UserPasswordCredential, the class had to be renamed in v3.

like image 3
dstrockis Avatar answered Nov 06 '22 22:11

dstrockis