Created
March 4, 2020 12:58
-
-
Save AnnejanBarelds/55ff9f4d109c5d84e5587c39361b8d46 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
private async Task<string> GetTokenAsync(string appId, X509Certificate2 certificate, string tenantId) | |
{ | |
var app = ConfidentialClientApplicationBuilder.Create(appId) | |
.WithAuthority($"https://login.microsoftonline.com/{tenantId}/") | |
.WithCertificate(certificate) | |
.Build(); | |
var scopes = new[] { "https://graph.microsoft.com/.default" }; | |
var result = await app.AcquireTokenForClient(scopes).ExecuteAsync(); | |
return result.AccessToken; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment