Hi Saira Munir,
Thank you reaching out, Microsoft!
The “Access Denied” error you are encountering is likely due to the type of permissions being used. In Graph Explorer, Calendars.ReadBasic
and Calendars.Read
are delegated permissions, which require the user to be signed in and consent to these permissions. However, to access other users’ calendars, you need to use application permissions instead of delegated permissions.
Solution Steps:
Register an Application in Azure AD:
- Go to the Azure portal and navigate to Azure Active Directory > App registrations > New registration.
- Enter a name for your application and click Register.
Configure API Permissions:
After registering the application, go to API permissions > Add a permission.
Select Microsoft Graph > Application permissions.
Add the required permissions such as Calendars.Read or Calendars.ReadWrite.
Grant Admin Consent:
Once the permissions are added, click on Grant admin consent for [Your Organization] to grant the necessary permissions.
Generate a Client Secret:
Go to Certificates & secrets > New client secret.
Add a description and set an expiration period, then click Add.
Copy the client secret value and store it securely.
Use the Application to Access Calendars:
- Use the client ID, tenant ID, and client secret to authenticate your application.
- Make API calls using the application permissions to access user calendars.
Please refer the below documents for more information:
https://learn.microsoft.com/en-us/graph/permissions-overview?tabs=http
https://learn.microsoft.com/en-us/graph/auth-register-app-v2
For testing application permission, you can use Postman with Graph. Please refer below doc for more details: https://learn.microsoft.com/en-us/graph/use-postman
If my answer is helpful to this question, please remember to "Accept as answer" to close this case and this will help people in this forum who have similar questions to yours find the answer easier.