1

I would like to create a backend Node.js aplication in order to manage an Outlook Calendar (Create, delete, update events...). However I want to update the same calendar every time (Always the same account). A global calendar to everyone.

The real pourpose is to integrate this calendar Backend with dialogFlow functionality (Similar to this example in Google Calendar https://github.com/dialogflow/fulfillment-bike-shop-nodejs)

I've been looking to https://learn.microsoft.com/en-us/graph/auth-v2-service, but I don't know if it is the correct aproach to do it.

I created an app in Azure Portal, and got my token:

POST https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token HTTP/1.1

But can't access to https://graph.microsoft.com/v1.0/users/{id}/calendars. The message I get is similar to this:

"code": "OrganizationFromTenantGuidNotFound",
"message": "The tenant for tenant guid '68cc4dcb-5873-4ea0-a498-fe57e9b5d827' does not exist."
Marc LaFleur
  • 31,987
  • 4
  • 37
  • 63
Oscar Saro
  • 35
  • 1
  • 5

1 Answers1

0

I've been looking to https://learn.microsoft.com/en-us/graph/auth-v2-service, but I don't know if it is the correct aproach to do it.

I think this is feasible.

"code": "OrganizationFromTenantGuidNotFound",

You need to use the user(tonyju@abc.onmicrosoft.com) to access calendars. And this account must have been assigned a O365 license You can refer to this.

enter image description here

Update:

If you just want to access the calendar of your personal account, you can use auth code flow to get the access token. And then use

https://graph.microsoft.com/v1.0/me/calendars
Tony Ju
  • 14,891
  • 3
  • 17
  • 31
  • Thanks, for your comment! The 'common' Tenant refers to this process https://learn.microsoft.com/es-es/graph/auth-v2-user ? – Oscar Saro May 01 '19 at 08:56
  • @OscarSaro The allowed values are common for both Microsoft accounts and work or school accounts, organizations for work or school accounts only, consumers for Microsoft accounts only – Tony Ju May 01 '19 at 09:02
  • @OscarSaro Referred to this one https://learn.microsoft.com/en-us/graph/auth-v2-service Get access without a user. – Tony Ju May 01 '19 at 09:11
  • I changed it, and sent the POST to https://login.microsoftonline.com/common/oauth2/v2.0/token. I received the Access Token. Should I do something else to get access to my Calendars from Graph API? – Oscar Saro May 01 '19 at 09:26
  • @OscarSaro Any error message when you access the graph api? – Tony Ju May 01 '19 at 09:30
  • Im not, i tried using the Token I received and my {id} (I got this ID from Azure Portal and Users -> My Microsoft Account with Office and the 'Object ID') but I get the following error: "code": "Authorization_IdentityNotFound", "message": "The identity of the calling application could not be established." – Oscar Saro May 01 '19 at 09:32
  • @OscarSaro What happened if you access https://graph.microsoft.com/v1.0/users/{id} with the access token? Have you added the permission for your application? – Tony Ju May 01 '19 at 09:37
  • @OscarSaro I can access the graph api successfully by using tenant name as the value of tenant https://login.microsoftonline.com/{tenant}/oauth2/v2.0/. Common doesn't work here. I will do some research regarding this. – Tony Ju May 01 '19 at 10:11
  • I already had it done, both Calendars.ReadWrite and Calendars.Read (Application) and Users.Read.All. I created a new Directory to register this application. Is this a problem? I will try with by using tenant name – Oscar Saro May 01 '19 at 10:13
  • With my directory tenant name I can access to graph.microsoft.com/v1.0/users{id} but when I try to use graph.microsoft.com/v1.0/users{id}/calendars I get the initial error "OrganizationFromTenantGuidNotFound" – Oscar Saro May 01 '19 at 10:19
  • @OscarSaro What do your account(email) and tenant name look like? Are they with the same domain? My user is user@abc.onmicrosoft.com(the office account), the tenant is abc.onmicrosoft.com – Tony Ju May 01 '19 at 12:00
  • My Microsoft Account is abc@gmail.com and the tenant is diferent eventsexample.onmicrosoft.com (I created a new directory from the default abc.onmicrosoft.com to create this application). – Oscar Saro May 01 '19 at 12:23
  • @OscarSaro Is abc.onmicrosoft.com your office365 tenant? – Tony Ju May 02 '19 at 05:55
  • @OscarSaro I have done some research regarding common endpoint. This is used for sign usage. If we want to get the access token with the permission. We still need to use the special tenant. https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token is ok. But you used wrong tenant for accessing the access token. – Tony Ju May 02 '19 at 05:59
  • @OscarSaro You need to use the user(tonyju@abc.onmicrosoft.com) to access calendars. And this account must have been assigned a O365 license – Tony Ju May 02 '19 at 06:33
  • So, I need to create a new user in my Azure Active Directory similar to: abc@{myTenant}.onmicrosoft.com and the buy a office 365 license? – Oscar Saro May 02 '19 at 09:47
  • @OscarSaro I thought you already have the Office 365 license. Yes, you must assign the o365 license to the user. I didn't try to assign a license to a guest user since I don't have any more license. – Tony Ju May 02 '19 at 09:55
  • I have the o365 personal license in my Microsoft account (abc@gmail.com). I would need another to the abc@{myTenant}.onmicrosoft.com ? – Oscar Saro May 02 '19 at 10:56
  • @OscarSaro Not exactly, if you just want to access the calendars of your personal account, you can use auth code flow to get the access token. https://learn.microsoft.com/en-us/azure/active-directory/develop/v1-protocols-oauth-code And the api will be https://graph.microsoft.com/v1.0/me/calendars. – Tony Ju May 03 '19 at 02:54
  • Thank you very much! I'll try it – Oscar Saro May 03 '19 at 09:59
  • @OscarSaro You are welcome. If you have any concerns regarding this or you need the detailed steps, you can post a new question. – Tony Ju May 03 '19 at 13:16