Good day SO people.
I am trying to create a REST web service to access MS Graph Calendar API. I would like to test this via postman first before I start to code. After some researching below is what I've reached so far.
- Created a Microsoft account with @outlook.com as domain and accessed the outlook utility. I went to the calendar display and plotted some events on the calendar.
- Used the account to enter Azure portal and created an Azure Active Directory and a new user in this tenant. I shared the calendar of my Microsoft account to this newly created AAD user.
- Used the newly created Azure active directory user to login into Microsoft App Registration Portal. I used this user because I saw in a blog that I need to register an application under "Converged Application". When I use my Microsoft account, there is no Converged Application section in the Application Registration Portal. Below is a screen capture.
- I added a "Converged Application" and got the necessary details like the Application ID and Application Secret Key. The platform that I chose is "Web" and I supplied this as redirect URL:
https://www.getpostman.com/oauth2/callback
. Although, I think I won't be using this because what I need is a seamless login. I don't want to spawn a browser for me to supply my Microsoft account for authorization and authentication.
Upon reading, there are many grant types for you to be authorized and authenticated to use MS Graph APIs. One is Authorization Code Grant Flow which spawns an interface for you to sign-in your Microsoft or AAD account. As mentioned above I need the seamless login so I've tried Client Credentials Grant Type
and Resource Owner Grant Type
.
- Upon creating the application, there are privileges that should be granted to it to control what it can access. I've given the required Delegated and Application permissions to the application in line with the specific MS Graph API that I need to use. Below is a screen capture.
Assuming that I'm all set, I tried to get an access token using this URL:
https://login.microsoftonline.com/substitute-with-tenant-directory-id/oauth2/v2.0/token
I was able to get an access token using the resource owner grant type. Below is the screen capture.
Next, I tried to access the specific API that I need. Here is the URL:
I've also tried to replace the "me" part in the URL with "users/substitute-with-user-id" but unfortunately I'm getting an error. Below is the screen capture.
I'm stuck because the response says "Unknown Error". Does anybody know what I am missing here?