I want to access other user calendars of my organization from my admin account on Microsoft office 365. On office 365 I can search and access those calendars. I want to Access these (other user's) calendars using Microsoft Graph API. Here are the official documentations for accessing office 365 calendar using Graph APIs. 1. Calendars from Users 2. Directly Access Calenders
Here is my Auth Helper class in which I am defining my permission scopes
module AuthHelper
CLIENT_ID = '91e6****-****-40f7-9b46-******d1149c'
CLIENT_SECRET = 'pftjo*******55;hwSN2-(%'
SCOPES = [ 'openid',
'profile',
'User.Read',
'Mail.Read',
'Calendars.Read',
'Calendars.Read.Shared' ]
def get_login_url
client = OAuth2::Client.new(CLIENT_ID,
CLIENT_SECRET,
:site => 'https://login.microsoftonline.com',
:authorize_url => '/common/oauth2/v2.0/authorize',
:token_url => '/common/oauth2/v2.0/token')
login_url = client.auth_code.authorize_url(:redirect_uri => authorize_url, :scope => SCOPES.join(' '))
end
def get_token_from_code(auth_code)
client = OAuth2::Client.new(CLIENT_ID,
CLIENT_SECRET,
:site => 'https://login.microsoftonline.com',
:authorize_url => '/common/oauth2/v2.0/authorize',
:token_url => '/common/oauth2/v2.0/token')
token = client.auth_code.get_token(auth_code,
:redirect_uri => authorize_url,
:scope => SCOPES.join(' '))
end
Trying postman:
https://graph.microsoft.com/v1.0/users query along with headers showing me all users but
GET /users/{id | userPrincipalName}/calendars query showing me 404 Not Found error.
In short, I can access other user's calendar from search bar of my office365 application but can not access using