Skip to content

Instantly share code, notes, and snippets.

@jpda
Created January 12, 2015 21:47
Show Gist options
  • Save jpda/7824fe03daaac6ff86fd to your computer and use it in GitHub Desktop.
Save jpda/7824fe03daaac6ff86fd to your computer and use it in GitHub Desktop.
AzureAdToken.cs
public static class AzureAdToken
{
public static string Get()
{
const string clientSecret = "CLIENT_SECRET";
const string clientId = "CLIENT_ID";
var ctx = new AuthenticationContext("https://login.windows.net/TENANT_NAME_OR_ID");
var token = ctx.AcquireToken("TARGET_RESOURCE", new ClientCredential(clientId, clientSecret));
return token.AccessToken;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment