Last active
May 11, 2024 09:15
-
-
Save LauraKokkarinen/83c5a6b883f68038a13d99eccc0ea00f 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
using Azure.Identity; | |
public async Task<string> GetAccessTokenAsync(string resourceUrl, string tenantId, string clientId, string clientSecret) | |
{ | |
var credential = new ClientSecretCredential(tenantId, clientId, clientSecret); | |
var accessToken = await credential.GetTokenAsync(new TokenRequestContext(scopes: [resourceUrl + "/.default"]) { }); | |
return accessToken.Token; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment