Home > Mobile >  What permissions are needed to read the Azure AD users' calendar via Graph API
What permissions are needed to read the Azure AD users' calendar via Graph API

Time:02-04

I need to access the calendars of Azure AD users. I do it with the code below:

var scopes = new[] { "https://graph.microsoft.com/.default" };

var tenantId = "MY_TENANT_ID";
var clientId = "APP_ID";
var clientSecret = "APP_SECRET";


var options = new TokenCredentialOptions
{
    AuthorityHost = AzureAuthorityHosts.AzurePublicCloud
};

var clientSecretCredential = new ClientSecretCredential(
    tenantId, clientId, clientSecret, options);

var graphClient = new GraphServiceClient(clientSecretCredential, scopes);

var user = await graphClient.Users["USER_ID"]
    .Calendar.Events
    .Request()
    .GetAsync();

As a result, I get the following error:

Status Code: Unauthorized

Microsoft.Graph.ServiceException: Code: NoPermissionsInAccessToken

Message: The token contains no permissions, or permissions can not be understood.

In Azure AD->App Registrations->API permissions I have got Calendars.Read permission, but don't have User.Read.All permission. So the question is can I get data from calendars without User.Read.All permission and if I can what am I doing wrong?

CodePudding user response:

According to your enter image description here

How to add application permission:

enter image description here enter image description here

  •  Tags:  
  • Related