-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
71 lines (60 loc) · 2.12 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using System;
using System.Threading.Tasks;
namespace GraphTutorial
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(".NET Core Graph Tutorial to fetch sensitivity labels of all files in a drive\n");
var appId = "";
var scopesString = "User.Read;Files.Read";
var scopes = scopesString.Split(';');
// Initialize Graph client
GraphHelper.Initialize(appId, scopes, (code, cancellation) => {
Console.WriteLine(code.Message);
return Task.FromResult(0);
});
var accessToken = GraphHelper.GetAccessTokenAsync(scopes).Result;
// </InitializationSnippet>
// <GetUserSnippet>
// Get signed in user
var user = GraphHelper.GetMeAsync().Result;
Console.WriteLine($"Welcome {user.DisplayName}!\n");
int choice = -1;
while (choice != 0) {
Console.WriteLine("Please choose one of the following options:");
Console.WriteLine("0. Exit");
Console.WriteLine("1. Fetch Files");
try
{
choice = int.Parse(Console.ReadLine());
}
catch (System.FormatException)
{
// Set to invalid value
choice = -1;
}
switch(choice)
{
case 0:
// Exit the program
Console.WriteLine("Goodbye...");
break;
case 1:
GetLabelsInALibrary();
break;
default:
Console.WriteLine("Invalid choice! Please try again.");
break;
}
}
}
static void GetLabelsInALibrary()
{
var files = GraphHelper.GetAllFilesAsync();
}
}
}