Reputation: 501
there are other questions about this, but I've not seen my exact situation and I'm not sure what I am doing wrong.
My app has a client secret set up and here are the api permissions
My code is pretty simple
var scopes = new[] { "https://graph.microsoft.com/.default" };
var tenantId = "tenenantid";
var clientId = "clientid";
var clientSecret = "secret";
var options = new TokenCredentialOptions
{
AuthorityHost = AzureAuthorityHosts.AzurePublicCloud
};
var clientSecretCredential = new ClientSecretCredential(
tenantId, clientId, clientSecret, options);
var graphClient = new GraphServiceClient(clientSecretCredential, scopes);
var calendars = await graphClient.Users["userIdhere"].Events.Request()
.GetAsync();
Upvotes: 0
Views: 91
Reputation: 22352
I tried to reproduce the same via Postman by granting same permissions and got the error as below:
To resolve the error, make sure to grant Application
permissions and grant admin consent as you are using client credentials grant flow:
After granting the Application
permissions, I got the list of calendar events successfully like below:
Reference:
List events - Microsoft Graph v1.0 | Microsoft Docs
Upvotes: 1