Last active
October 7, 2019 16:40
-
-
Save BrianTJackett/3c629bca714325440cffce73e6b3bf56 to your computer and use it in GitHub Desktop.
Microsoft Graph C# .Net Core prepare GraphServiceClient
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
var clientId = "<AzureADAppClientId>"; | |
var clientSecret = "<AzureADAppClientSecret>"; | |
var redirectUri = "<AzureADAppRedirectUri>"; | |
var authority = "https://login.microsoftonline.com/<AzureADAppTenantId>/v2.0"; | |
var cca = ConfidentialClientApplicationBuilder.Create(clientId) | |
.WithAuthority(authority) | |
.WithRedirectUri(redirectUri) | |
.WithClientSecret(clientSecret) | |
.Build(); | |
// use the default permissions assigned from within the Azure AD app registration portal | |
List<string> scopes = new List<string>(); | |
scopes.Add("https://graph.microsoft.com/.default"); | |
var authenticationProvider = new MsalAuthenticationProvider(cca, scopes.ToArray()); | |
GraphServiceClient graphClient = new GraphServiceClient(authenticationProvider); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment