Created
April 3, 2019 16:35
-
-
Save dylan-asos/2042c927fc6fd849111561fdcb226b08 to your computer and use it in GitHub Desktop.
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 class MetricsApiAccessTokenProvider | |
{ | |
private readonly CredentialConfiguration _settings; | |
public MetricsApiAccessTokenProvider(CredentialConfiguration settings) | |
{ | |
_settings = settings; | |
} | |
public async Task<string> GetAccessToken() | |
{ | |
var clientCredentials = new ClientCredential(_settings.ClientId, _settings.Secret); | |
var context = new AuthenticationContext($"https://login.microsoftonline.com/{_settings.TenantId}"); | |
var result = await context.AcquireTokenAsync("https://monitoring.azure.com/", clientCredentials); | |
return result.AccessToken; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment