
All examples that I have found to authenticate to CRM Web API use AcquireToken method, passing resourceUrl, clientId and redirectUrl. We recently updated our Intranet MVC 5 web app to Active Directory Authentication Library (ADAL) 3.10. This version does not have AcquireToken, but uses AcquireTokenAsync method. Unfortunately, there is no AcquireTokenAsync method with these 3 parameters. I need help to figure out what would be the equivalent process to authenticate to the CRM Web API service using the latest version of ADAL.
*This post is locked for comments
I have the same question (0)Hope this helps
private static async Task GetTokenSilent() { // Before create AuthenticationContext, check if Authority(OAuthUrl) is available. if (String.IsNullOrEmpty(OAuthUrl)) { bool success = true; try { await DiscoveryAuthority(); } catch (Exception) { // If failed to retireve OAuthUrl, then make success as false success = false; } // If failed to retrieve OAuthUrl, chances are user mistype ServerUrl. if (!success) { await Utility.ShowMessage("OAuth Url retrieve failed. Please check Service URL again."); return; } } if (SignOut) { if (authContext != null) authContext.TokenCache.Clear(); SignOut = false; } // Create AuthenticationContext by using OAuthUrl. if (authContext == null) authContext = new AuthenticationContext(OAuthUrl, false); // Try to acquire token without prompting user first. AuthenticationResult result = await authContext.AcquireTokenSilentAsync(ResourceName, ClientId); // Check the result. if (result != null && result.Status == AuthenticationStatus.Success) { // A token was successfully retrieved. Then store it. StoreToken(result); return; } //Clear AccessToken _xrmProxy.AccessToken = ""; authContext.TokenCache.Clear(); // Trigger an authentication experience and specify that once a token has been obtained the StoreToken method should be called. result = await authContext.AcquireTokenAsync(ResourceName, ClientId, RedirectUri); StoreToken(result); }