In the application itself the code to call the CRM Web API looks identical to the C# example I had previously posted. The real difference is that this time around we're not using ADAL to handle authentication. UWP applications can use the new WebAccountProvider which is native to Windows 10. If you’re targeting also targeting previous versions of Windows you’ll need to fall back to ADAL. You can check out a great blog post on the subject here:
Here’s what the basic authentication would look like.
//Azure Application Client ID private const string _clientId = "00000000-0000-0000-0000-000000000000"; //CRM URL private const string _resource = "https://org.crm.dynamics.com"; //Azure Directory OAUTH 2.0 AUTHORIZATION ENDPOINT private const string _authority = "https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000"; private static string _accessToken; WebAccountProvider wap = await WebAuthenticationCoreManager.FindAccountProviderAsync( "https://login.microsoft.com", _authority); WebTokenRequest wtr = new WebTokenRequest(wap, string.Empty, _clientId); wtr.Properties.Add("resource", _resource); WebTokenRequestResult wtrr = await WebAuthenticationCoreManager.RequestTokenAsync(wtr); _accessToken = wtrr.ResponseData.Token;
You can check out the code on GitHub: