Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

azure active directory - Calendar endpoint returns OrganizationFromTenantGuidNotFound

I'm currently trying to achieve in Node.js a direct login to Calendar/Users using Microsoft Graph.

What I've done so far are the following:

  1. Login on the account and make sure that it currently has a calendar (the email is registered under @outlook.com).

  2. Go to azure portal and create a new AAD name "Calendar Api" web API with return URL http://localhost:3000

  3. AAD -> App Registration -> Name: Test, reply url: localhost:3000, Required Permissions for Microsoft Graph (Users Read/Write, Calendars Read/Write), Windows AAD (offline_access), Grant Permissions, Generated a new secret key with no expiry date.

  4. Went to Postman and started to generate a new token based on the following URL:

https://login.microsoftonline.com/{APP_ID_URI}.onmicrosoft.com/oauth2/v2.0/token
  • grant_type : client_credentials
  • client_id : {app_id}
  • client_secret : {app_secret}
  • scope : https://graph.microsoft.com/.default

And I a 200 OK with a token.

  1. Upon inspecting the token:
"aud": "https://graph.microsoft.com",
    "roles": [
        "User.ReadWrite.All",
        "Calendars.Read",
        "Calendars.ReadWrite"
        ],
  1. GET ON -> https://graph.microsoft.com/v1.0/users/ with Authorization Bearer and the above token will return a code status 200 along with the user account I've used in step 1.

  2. GET ON -> https://graph.microsoft.com/v1.0/calendars/ with Authorization Bearer and the above token returns "Resource not found for the segment 'calendars'."

  3. GET ON -> https://graph.microsoft.com/v1.0/users/{user_id}/calendars OR /calendar OR /calendarView:

"code": "OrganizationFromTenantGuidNotFound",
"message": "The tenant for tenant guid '104fdcd9-76d1-4122-89a0-30cb00722de2' does not exist."

I don't really have a code because I am using POSTMAN to test the API first.

I would expect to get a list of events or a list of calendars instead of an error.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

After some digging I found out what the problem was, so here is the full solution to this question.

  1. You need a microsoft office 365 account with subscription, can get this by applying for one on office 365 develop.
  2. Upon creating one, follow the instructions and add the apps to it.
  3. Go to Azure Portal and log in with your office 365 account.
  4. Create an app under AAD -> App registration
  5. Follow step 4 and 5 of this question.
  6. Try to access https://graph.microsoft.com/v1.0/users/{user_id}/calendars.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...