Skip to content

Instantly share code, notes, and snippets.

@darrelmiller
Created March 19, 2019 00:39
Show Gist options
  • Save darrelmiller/75264a5850a62114adea4c33a44a4779 to your computer and use it in GitHub Desktop.
Save darrelmiller/75264a5850a62114adea4c33a44a4779 to your computer and use it in GitHub Desktop.
class Program
{
static void Main(string[] args)
{
AsyncMain().GetAwaiter().GetResult();
Console.Read();
}
static async Task AsyncMain()
{
// Create Client Application and Authentication Provider
var app = InteractiveAuthenticationProvider.CreateClientApplication("5dba030e-37f3-4adc-8eb8-3e2e9e68aa0f");
var authProviders = new InteractiveAuthenticationProvider(app, new string[] { "User.Read"});
// Create GraphServiceClient with middleware pipeline setup
var graphServiceClient = new GraphServiceClient(authProviders);
// Request using default app permissions
var user = await graphServiceClient.Me.Request().GetAsync();
Console.WriteLine($"User: {user.DisplayName}");
// Incremental Consent
var messages = await graphServiceClient.Me.Messages.Request()
.WithScopes(new string[] { "Mail.Read" })
.GetAsync();
Console.WriteLine($"Messages Count: {messages.Count}");
Console.Read();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment