Reputation: 155
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.
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
.
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?
Upvotes: 4
Views: 5769
Reputation: 838
Below things worked for me:
1) Create a access token from Authorization tab, select the type as OAuth 2.0 and click on GET NEW ACCESS TOKEN.
2) Enter the details like below:
Auth URL : https://login.windows.net/common/oauth2/authorize?resource=https://outlook.office.com
Access Token URL : https://login.microsoftonline.com/common/oauth2/token
Client ID: your application id
Secret: secret set while app registration.
3) It will authenticate and token will be created.
4) Select Add token to Header and click on Use Token button.
5) In Body tab select x-www-form.
6) In Header tab it should look like below:
Content-Type : application/x-www-form-urlencoded
Authorization : Bearer (your token generated automatically).
7) Perform POST Operation.
Upvotes: 1
Reputation: 777
I have recently called Graph API via postman by following the steps given on This Blog
and I think the issue is you are not passing Resource
in body. Try to pass the Resource
in a body with value https://graph.microsoft.com
hope this will solve your issue.
Upvotes: 1
Reputation: 85
It is delegated permission token, you can only get current login user's calendar event. If you want to load other user's event, you can use app-only token. Refer to https://developer.microsoft.com/en-us/graph/docs/concepts/auth_v2_service to know how to get app-only token.
Upvotes: 1