Office 365 api in PHP Office 365 api in PHP php php

Office 365 api in PHP


According the error list at https://graph.microsoft.io/en-us/docs/overview/errors, when you get the 401 error, it means

Required authentication information is either missing or not valid for the resource.

It may be that your access token doesn't contain the scope for the resource your application requesting. E.g.

If you want to list the resource of calendar view, and according the document at https://graph.microsoft.io/en-us/docs/api-reference/v1.0/api/user_list_calendarview:

One of the following scopes is required to execute this API: Calendars.Read; Calendars.ReadWrite

Please login the portal of your Azure AD application, check the permissions Have full access to user calendars or Read user calendars of Microsoft Graph whether have been marked.

And you can check the "scope" section of the response body with your access token, refer to https://azure.microsoft.com/en-us/documentation/articles/active-directory-protocols-oauth-code/#use-the-authorization-code-to-request-an-access-token for more info.