0
votes

I am able to authenticate with MSAL and retrieve the calendar's events in a Listview

However this is not what I want, is it possible to list out the whole calendar from outlook?enter image description here

GraphServiceClient graphClient = new GraphServiceClient( authProvider );

    var calendar = await graphClient.Me.Calendar
        .Request()
        .GetAsync();

Tried using both of these but theres nothing displaying.

var queryOptions = new List<QueryOption>()
{
    new QueryOption("startDateTime", "2017-01-01T19:00:00-08:00"),
    new QueryOption("endDateTime", "2017-01-07T19:00:00-08:00")
};

var calendarView = await graphClient.Me.Calendar.CalendarView
    .Request( queryOptions )
    .GetAsync();

Can I assume I need to create my own layout/calendar to store the events?

I am fairing new to C# so please bare with me.

1

1 Answers

0
votes

Microsoft Graph API ensures that the app can communicate with Outlook.com (Microsoft Account) or Office 365 (Enterprise Account). So you could invoked the following code in Code Behind .

var client = new GraphServiceClient("https://graph.microsoft.com/v1.0",
      new DelegateAuthenticationProvider(
      async (requestMessage) =>
      {
         var tokenRequest = await App.IdentityClientApp.AcquireTokenSilentAsync(App.Scopes, App.IdentityClientApp.Users.FirstOrDefault());
         requestMessage.Headers.Authorization = new AuthenticationHeaderValue("bearer", tokenRequest.AccessToken);
      })); 
   var events = await client.Me.Events.Request().GetAsync();
   var list = events.ToList();
   YourListView.ItemsSource = list.Take(5);

Here is a full blog that maybe can help you .