1

I'm currently developing a small managing app that should create events within a specific Microsoft calendar but I'm only able to do this for me as the authorized user.

Is there an option to create events for everyone in this calendar with only knowing the userPrincipalName?

{
  "subject": "test",
  "body": {
    "contentType": "HTML",
    "content": "Sample Text"
  },
  "start": {
      "dateTime": "2019-04-04T12:00:00",
      "timeZone": "Pacific Standard Time"
  },
  "end": {
      "dateTime": "2019-04-04T14:00:00",
      "timeZone": "Pacific Standard Time"
  },
  "location":{
      "displayName":"Testlocation"
  }
}

https://graph.microsoft.com/v1.0/users/myPricipalName/calendar/events works but only for me.

The whole documentation is a bit overwhelming

pguetschow
  • 5,176
  • 6
  • 32
  • 45
  • Anyone know answer for my query ? https://stackoverflow.com/questions/60880089/microsoft-graph-api-in-laravel-controller – ABHILASHA K.M Mar 27 '20 at 07:31

2 Answers2

6

The answer is yes, but you're right about the documentation...

You'll have to take the following steps:

  1. Create an application documentation
  2. Add the following permission Read and write calendars in all mailboxes for the Microsoft Graph API.
  3. Grant the permission for your tenant (the easiest way is through https://portal.azure.com -> Azure AD -> App Registrations -> Your App -> Settings -> Required permissions -> Button Grant Access.
  4. Request a token with the client id and secret, this is called the Client credentials flow documentation
  5. (optional) Inspect the token on https://jwt.ms to see if the token is correct.
  6. Create an event documentation
  7. Celebrate your accomplishment with some refreshments.
Stephan
  • 2,356
  • 16
  • 38
  • provided steps are detailed but do you have any documentation link where example for `client_credential` workflow. Your step no 6 shows examples for logged-in users only and not for daemon service. – Mahesh More Jun 03 '21 at 10:28
  • In step 4 you see a link to how to get a token for the client credentials... after that it’s just as creating an event for the current user, but the url has to be /users/upn@domain.com/ instead of /me – Stephan Jun 03 '21 at 16:57
  • For reference's sake, I'm adding a link to documentation where it _does_ specify you can create an event with app-only permission although it assumes you already know very well how app-only permissions work and how are they different from user (delegated) permissions. [Calendar Permissions](https://learn.microsoft.com/en-us/graph/permissions-reference#calendars-permissions) - See Application section in particular. – JDuarteDJ Oct 21 '21 at 10:21
0

The best approach would be to get an application token, an application which has been granted permission to write users’ calendars.

AOwens
  • 43
  • 4