Last active
May 1, 2019 21:24
-
-
Save emregulcan/d82a564bb977780ab4eb6d04bc23734d to your computer and use it in GitHub Desktop.
Dynamics 365 CE (CRM) Web API Authentication by using ADAL (Active Directory Authentication Library)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public string RetrieveAuthToken(string authorityURI, string d365Url, string clientId, string clientSecret) | |
| { | |
| string result = string.Empty; | |
| ClientCredential clientCredential = new ClientCredential(clientId, clientSecret); | |
| AuthenticationContext authenticationContext = new AuthenticationContext(authorityURI, false); | |
| var authenticationResult = authenticationContext.AcquireTokenAsync(d365Url, clientCredential).GetAwaiter().GetResult(); | |
| result = authenticationResult.AccessToken; | |
| return result; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment