Access denied Microsoft Graph Deamon App with SDK Outlook List of Events, with Rights set

Reto Rümmeli 5 Reputation points
2023-02-13T07:02:44.9333333+00:00

Hi Roboter

Access denied Microsoft Graph Deamon App with SDK Outlook List of Events, with Rights set

I have set up a new application in Azure and reset the permissions several times. (see the Permissions below)

But unfortunately it does not work

I wonder why the Event.add, Event.update and Event.delete queries work, but the listing does not.
All rights I have setup the rights on.
Can someone please give me correct and qualified information why it does not work?

Many Thanks

Here is the code for creating the GraphserviceClient.

public GraphServiceClient GetGraphClientWithIdentity() {

        if (_graphServiceClient != null)
            return _graphServiceClient;

        var instance = _configuration.GetValue<string>("AzureAd:Instance");
        var apiurl = _configuration.GetValue<string>("AzureAd:ApiUrl");
        var tenant = _configuration.GetValue<string>("AzureAd:Tenant");
        var tenantId = _configuration.GetValue<string>("AzureAd:TenantId");
        var clientId = _configuration.GetValue<string>("AzureAd:ClientId");
        var clientSecret = _configuration.GetValue<string>("AzureAd:ClientSecret");
        string[] scopes = new[] { "https://graph.microsoft.com/.default" };
        
        //var authority = String.Format(CultureInfo.InvariantCulture, instance, tenant);

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

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

        return graphClient;

    }

Here is the code for the requests that work.

// Create Client
var graphClient = _graphClient.GetGraphClientWithIdentity();
// OK
users = await graphClient.Users.Request().GetAsync(); calendars = await graphClient.Users[userid].Calendars.Request().GetAsync(); mailfolders = await graphClient.Users[userid].MailFolders.Request().GetAsync(); organizations = await graphClient.Organization.Request().GetAsync(); categories = await graphClient.Users[userid].Outlook.MasterCategories.Request().GetAsync();  var evsendInsert = await graphClientService.Users[userid_1].Events.Request().AddAsync(@event); // Event Update OK var evsendUpdate = await graphClientService.Users[userid_1].Events[eventid].Request().UpdateAsync(@event); // Event Delete OK await graphClientService.Users[userid_1].Events[eventid].Request().DeleteAsync();

// Do not Work
var events = await graphClient.Users[userid].Events.Request().GetAsync();
var events = await graphClient.Users[userid].Calendars[firstCalendarID].Events.Request().GetAsync();

The rights

Calendars.Read

Calendars.ReadBasic.All

Calendars.ReadWrite

Directory.Read.All

Directory.ReadWrite.All

Group.Read.All

Group.ReadWrite.All

Mail.Read

Mail.ReadBasic

Mail.ReadBasic.All

Mail.ReadWrite

Mail.Send

User.Read

User.Read.All

User.ReadBasic.All

User.ReadWrite.All

User's image

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,308 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Codelab.com 0 Reputation points
    2023-02-20T08:22:31.62+00:00

    Any News about this?

    0 comments No comments

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  3. Zehui Yao_MSFT 5,871 Reputation points
    2023-02-20T10:12:07.2666667+00:00

    Hi @Reto Rümmeli , I set the same permissions as you and can reproduce the same error. Then after my testing, I found that when the Calendars.ReadBasic.All permission was granted, I couldn't list events. When the Calendars.ReadBasic.Allpermission is removed, the API can run successfully.

    It looks like the Calendars.ReadBasic.All permission conflicts with other permissions.

    Hope that can help you. Best Wishes.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


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.