Sang
Sang

Reputation: 11

Return 401 Unauthorized when use Graph API to read calendar and mailbox setting

I have setup a work account on Azure and add permissions "User.ReadBasic.All", "MailboxSettings.Read", "Calendars.ReadBasic.All" with application type

  1. I can use client credential flow to get the access token successfully
https://login.microsoftonline.com/{tenant-id}/oauth2/v2.0/token

the token can be parsed by https://jwt.ms with proper role

"roles": [ "User.ReadBasic.All", "MailboxSettings.Read", "Calendars.ReadBasic.All" ]

  1. I can query user information successfully using the token
https://graph.microsoft.com/v1.0/users/{userid}
  1. But it returns error 401 when query calendar or mailboxSettings
https://graph.microsoft.com/v1.0/users/{userid}/calendar/calendarView?startdatetime=2021-12-23T08%3A00%3A00.000Z&enddatetime=2022-12-23T18%3A00%3A00.000Z

https://graph.microsoft.com/v1.0/users/{userid}/mailboxSettings

Both return error below

{ "error": { "code": "UnknownError", "message": "", "innerError": { "date": "2023-01-05T11:06:14", "request-id": "xxx", "client-request-id": "xxxx" } } }

  1. Is "MailboxSettings.Read" and "Calendars.ReadBasic.All" enough for the above query, or need more permissions like Calendars.Read / Calendars.ReadWrite / MailboxSettings.ReadWrite ?

  2. Also for permission of calendar, which one is a higher permission, is the below correct?

Calendars.Read < Calendars.ReadBasic.All

Upvotes: 0

Views: 391

Answers (1)

vicky kumar
vicky kumar

Reputation: 740

Could you please try by providing user.ReadAll permission instead of User.ReadBasic.All

Upvotes: 1

Related Questions