We require Realm URL, Client ID, Client Secret.
Using above key we can fetch the access token as follows.
var realm = “RealmURL”;
var authContext = new AuthenticationContext(“AuthURL”);
var userCreds = new ClientCredential(“ClientId”, “ClientSecret”);
authenticationResult = authContext.AcquireTokenAsync(realm, userCreds).Result;
if (authenticationResult != null && !string.IsNullOrEmpty(authenticationResult.AccessToken))
accessToken = authenticationResult.AccessToken;