Link to home
Start Free TrialLog in
Avatar of drupal_100
drupal_100Flag for United States of America

asked on

PHP app to get Office 365 data using Graph API and Client Credentials

We are developing PHP program to get Office 365 data, such as calendar.
Use Office 365 Home account.
Use Microsoft Graph API.
Use client credentials grant type.

We can get token, user profile, but can not get calendar.

https://docs.microsoft.com/en-us/graph/auth-v2-service 
Follow this document,
[1] Register app - OK
[2] Configure for Microsoft Graph - OK
Calendars.Read Application Read calendars in all mailboxes
Calendars.ReadWrite Application Read and write calendars in all mailboxes
User.Read.All Application Read all users' full profiles
User.ReadWrite.All Application Read and write all users' full profiles

[3] Get administrator consent - OK
[4] Get access token - OK
[5] Use access token to call Microsoft Graph
Get user - OK works well to get user profile
Get calendar - not working
{
  "error": {
    "code": "OrganizationFromTenantGuidNotFound",
    "message": "The tenant for tenant guid '<tenant-ID>' does not exist.",
    "innerError": {
      "request-id": "<request-id>",
      "date": "2019-09-20T20:15:31"
    }
  }
}
Avatar of Saif Shaikh
Saif Shaikh
Flag of India image

I think after research all a pointing to only one thing: i.e. register the app in your O365 AAD tenant that you got when you created the development tenant.

Reference Articles:
https://stackoverflow.com/questions/55263690/microsoft-graph-api-graphorganizationfromtenantguidnotfound-error-code?noredirect=1&lq=1

https://stackoverflow.com/questions/54347728/microsoft-graph-api-calendar-endpoint-returns-organizationfromtenantguidnotfou
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.