Archive
Posts Tagged ‘UserPasswordCredential’
Web API Helper Code Compilation Error
September 18, 2018
Leave a comment
I was creating a console application to connect to Dynamics 365 Web API, and downloaded “Microsoft.CrmSdk.WebApi.Samples.HelperCode” NuGet package.
I got “AcquireToken method is no longer available” compilation error, when I build the project
Reason & Fix:
- We have to use UserPasswordCredential class in ADAL v3.
- Below is the code snippet
var credentials = new UserPasswordCredential(userName, password);
var context = new AuthenticationContext(authorityUri);
authResult = context.AcquireTokenAsync(serviceUrl, applicationId, credentials).Result;
Refer my previous article for step by step to connect to Dynamics 365 Web API.
🙂