Home > Azure > Get access token to call Microsoft Azure api

Get access token to call Microsoft Azure api

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;

 
This Article is TAGGED in . BOOKMARK THE permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">