MS Graph API: Reading multiple users calendar free/busy data with restricted access to calendars

ToniMartikainen-1813 0 Reputation points
2023-06-12T08:44:14.04+00:00

Hello All!

We have a scheduler application which is used to read and write users calendars by using MS Graph API.

In Azure, we have registered an application which has a Calendar.ReadWrite Application permission to read and write users calendars. We also have a (technical) user added into the appliation member, so we can use that technical user to access the other users' calendars like this POST /users/<technical_user@some.domain>/calendar/getSchedule, and adding the users SMTP addresses into the HTTP request body, like in here https://learn.microsoft.com/en-us/graph/api/calendar-getschedule?view=graph-rest-1.0&tabs=http#response-1

The problem here is, that the technical user can access all users calendars, and we would like to restrict the access only to specified calendars. We are planning to use ApplicationAccessPolicy by creating a Mail-enabled security group and adding those specified users into that group. And then use the New-ApplicationAccessPolicy PowerShell command to apply the security group for the Application.

But, when we add the policy, we get the following error

{
  "error": {
    "code": "ErrorAccessDenied",
    "message": "Access to OData is disabled."
  }
}

What might be causing this? We are running out of ideas, and any help would be greatly appreciated.

Outlook Windows Classic Outlook for Windows For business
Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ab-8756 805 Reputation points
    2023-06-12T12:15:11.9966667+00:00

    Hello ToniMartikainen-1813,
    Thank you for reaching out.

    Looking at your error, it seems like the issue is related to the EwsApplicationAccessPolicy. Please run "Get-OrganizationConfig | select EwsApplicationAccessPolicy, EwsAllowList, EwsBlockList"
    See if EwsApplicationAccessPolicy is set to EnforceAllowList which means only the applications (user agent strings) configured in EwsAllowList are able to access EWS. If EwsAllowList is empty, that means there is no application which is allowed to access EWS.
    Please go through this article for further details;- https://learn.microsoft.com/en-us/archive/blogs/wushuai/how-to-fix-access-to-odata-is-disabled-when-calling-graph-api
    Please also check whether a user-specific policy has been applied;- Get-CASMailbox <user-principal-name> | fl EwsApplicationAccessPolicy,EWS*List

    Hope that helps.
    Thanks
    --please don't forget to upvote and Accept as answer if the reply is helpful--


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.