I have a node.js/express application. I am trying to use the Microsoft Graph API to fetch users' Calendars [read-only].
OAuth2 library for login: passport-microsoft npm module.
I followed the following steps in the Azure Portal:
Go to Active Directory
Click on App Registrations in the left pane
- Click on New Registration and create an app
- Go to the new app
- Click on Authentication in the left panel and add redirect URI's
Go to API Permissions and enable the following :
a. Delegated: Calendars.Read, Calendars.Read.Shared, profile
- Provide Admin Consent for all the permissions that require it.
However, only users who belong to my azure organisation, under which I have registered my web application, are able to login.
Other organisation users are unable to login. I get the following error message:
2019-11-11 10:16:35 default[20191109t101750] InternalOAuthError: failed to fetch user profile
2019-11-11 10:16:35 default[20191109t101750] at /srv/node_modules/passport-microsoft/lib/strategy.js:86:29
2019-11-11 10:16:35 default[20191109t101750] at passBackControl (/srv/node_modules/oauth/lib/oauth2.js:132:9)
2019-11-11 10:16:35 default[20191109t101750] at IncomingMessage.<anonymous> (/srv/node_modules/oauth/lib/oauth2.js:157:7)
2019-11-11 10:16:35 default[20191109t101750] at IncomingMessage.emit (events.js:203:15)
2019-11-11 10:16:35 default[20191109t101750] at IncomingMessage.EventEmitter.emit (domain.js:466:23)
2019-11-11 10:16:35 default[20191109t101750] at endReadableNT (_stream_readable.js:1145:12)
2019-11-11 10:16:35 default[20191109t101750] at process._tickCallback (internal/process/next_tick.js:63:19)
You can read my previous question for reference here