Created
January 12, 2015 21:47
-
-
Save jpda/7824fe03daaac6ff86fd to your computer and use it in GitHub Desktop.
AzureAdToken.cs
This file contains 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 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