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:
Login on the account and make sure that it currently has a calendar (the email is registered under
@outlook.com).Go to azure portal and create a new AAD name "Calendar Api" web API with return URL
http://localhost:3000AAD -> 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.
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.
- Upon inspecting the token:
"aud": "https://graph.microsoft.com",
"roles": [
"User.ReadWrite.All",
"Calendars.Read",
"Calendars.ReadWrite"
],
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.GET ON ->
https://graph.microsoft.com/v1.0/calendars/with Authorization Bearer and the above token returns"Resource not found for the segment 'calendars'."GET ON ->
https://graph.microsoft.com/v1.0/users/{user_id}/calendarsOR/calendarOR/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.