public static string GetOAuthTokenFromAAD()
{
var authenticationContext = new AuthenticationContext(String.Format("{0}/{1}",
ConfigurationManager.AppSettings["ADALServiceURL"],
ConfigurationManager.AppSettings["TenantDomain"]));
//Ask the logged in user to authenticate, so that this client app can get a token on his behalf
var result = authenticationContext.AcquireToken(String.Format("{0}/", ConfigurationManager.AppSettings["ARMBillingServiceURL"]),
ConfigurationManager.AppSettings["ClientID"],
new Uri(ConfigurationManager.AppSettings["ADALRedirectURL"]),
PromptBehavior.Always);
if (result == null)
{
throw new InvalidOperationException("Failed to obtain the JWT token");
}
return result.AccessToken;
}