Create a Windows service project to Add Events using Microsoft Graph
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[] { "https://graph.microsoft.com/.default" };
IConfidentialClientApplication app;
app = ConfidentialClientApplicationBuilder.Create(clientId)
.WithClientSecret(clientSecret)
.WithTenantId(tenantId)
.Build();
AuthenticationResult result = null;
try
{
result = await app.AcquireTokenForClient(scopes)
.ExecuteAsync();
}
catch (ServiceException e)
{
}
return result.AccessToken;
then i am using "https://graph.microsoft.com/v1.0/users/"+ UserId +"/events"; to create the events but its not working at all
**Error : Access is denied. Check credentials and try again
**
Thanks
Udal