Create a Windows service project to Add Events using Microsoft Graph

Udal Bharti 0 Reputation points

Dear Members,

I am developing a Windows service project which will create events using Microsoft Graph API.
I chosen window service as my program will pull events from database and push in Outlook Calendar using Graph API.

At first in azure portal i have registered my application as Mobile and desktop app and give permission. I have delegated permissions in azure for Calendar.ReadWrite.
I am successfully getting token using this below code where i used this as scope

   var scopes = new string[] { "" };
IConfidentialClientApplication app;

            app = ConfidentialClientApplicationBuilder.Create(clientId)

            AuthenticationResult result = null;
                result = await app.AcquireTokenForClient(scopes)


            catch (ServiceException e)

            return result.AccessToken;

then i am using ""+ UserId +"/events"; to create the events but its not working at all

**Error : Access is denied. Check credentials and try again


Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
2,105 questions
Microsoft Graph Calendar API
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
9,018 questions
{count} votes