Created
March 19, 2019 00:39
-
-
Save darrelmiller/75264a5850a62114adea4c33a44a4779 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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