0
votes

As a office 365 admin, Can I subscribe to listen events of other 365 users events on microsoft graph? I can get events for me https://graph.microsoft.com/v1.0/me/events OR "/v1.0/users/[email protected]/events" --Works Fine...But when as a Admin tries to get events details for other users. I get error
"message": "Access is denied. Check credentials and try again.", https://graph.microsoft.com/v1.0/users/[email protected]

Is it possible to fetch event details for other users? if yes then please let me know any setting missing at admin side. if not then what is differnece between api with "/v1.0/users/" and "/v1.0/me/"

2

2 Answers

1
votes

Yes. You can use Client Credential flow to get the app-token for the app. And please ensure that the app you register have the Calendars.Read scope to read calendars in all mailboxes like figure below:

enter image description here

Please refer here for more detail.

Code request for app-only token:

  public static async Task<string> GetTokenAsync(string resource, string clientId, string secrect)
    {
        string authority = "https://login.microsoftonline.com/{yourtenant}";
        AuthenticationContext authContext = new AuthenticationContext(authority);

        ClientCredential clientCredential = new ClientCredential(clientId, secrect);
        AuthenticationResult authResult=await authContext.AcquireTokenAsync(resource, clientCredential);
        return authResult.AccessToken;
    }

  public static void GetAccessTokenByClientCredential()
    {
        string clientId = "";
        string secrect = "";
        string resrouce = "https://graph.microsoft.com";
        string accessToken= TokenHelper.GetTokenAsync(resrouce, clientId, secrect).Result;
        Console.WriteLine($"Access Token: {accessToken}");

    }
0
votes

As per microsoft guy to view another user's calendar using /events endpoint, you need a special permission (something like Calendar.Read.Shared) that we are still in the process of adding,Please have a look at below link..

Microsoft Graph api 403 access denied when reading other users

This thread was posted on 21 Apr 16 by Venkat Ayyadevara - MSFT, I guess still is in progress.