· 6 years ago · Feb 28, 2019, 04:58 PM
1public static async Task<string> GetAccessToken(string azureTenantId, string azureAppId, string azureSecretKey)
2 {
3 var context = new AuthenticationContext(ConfigurationManager.AppSettings.Get("Authority") + tenantId);
4 ClientCredential clientCredential = new ClientCredential(appId, secretKey);
5 var tokenResponse = await context.AcquireTokenAsync(ConfigurationManager.AppSettings.Get("VaultUrl"), clientCredential);
6 var accessToken = tokenResponse.AccessToken;
7 return accessToken;
8 }