Hi BhanuKiran
I must preface that this is my first experience with the Graph SDK. I am developing a Deamon application.
I have set up a new application in Azure and reset the permissions. (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.
Here is the code for creating the GraphserviceClient. Here i dont see the Token.
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();
Here all the Permissions.