ADAL.NET v3 does not support AcquireToken with UserCredential?

前端 未结 4 999
无人共我
无人共我 2020-12-10 03:22

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 Authen         


        
相关标签:
4条回答
  • 2020-12-10 03:37

    Use UserPasswordCredential class instead which is a subclass of UserCredential

    0 讨论(0)
  • 2020-12-10 03:37

    FYI, it seems as though they have removed this functionality from ADAL. source

    To authenticate with a users username/password combo, I believe you will have to use HttpClient and make the post request yourself.

    Post to:

    https://login.microsoftonline.com/yourdomain.onmicrosoft.com/oauth2/token
    

    with:

    resource={resource}&client_id={clientid}&grant_type=password&username={username}&password={password}&scope=openid&client_secret={clientsecret}
    

    in the request

    0 讨论(0)
  • 2020-12-10 03:54

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

    0 讨论(0)
  • 2020-12-10 03:58

    This fixes the issue for the UserCredentials, but you also seems to be a change to the AuthenticationContext type which no longer seems to have an AcquireToken method. You can address this by using AcquireTokenAsync

    0 讨论(0)
提交回复
热议问题