[英]calling microsoft graph api via postman
Good day SO people. 美好的一天SO人。
I am trying to create a REST web service to access MS Graph Calendar API. 我正在尝试创建一个REST Web服务来访问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
. https://www.getpostman.com/oauth2/callback
: https://www.getpostman.com/oauth2/callback
。 Although, I think I won't be using this because what I need is a seamless login. Upon reading, there are many grant types for you to be authorized and authenticated to use MS Graph APIs. 在阅读时,有许多授权类型供您授权和验证以使用MS Graph API。 One is Authorization Code Grant Flow which spawns an interface for you to sign-in your Microsoft or AAD account.
一个是授权代码授权流程 ,它为您提供登录Microsoft或AAD帐户的界面。 As mentioned above I need the seamless login so I've tried
Client Credentials Grant Type
and Resource Owner Grant Type
. 如上所述,我需要无缝登录,所以我尝试过
Client Credentials Grant Type
和Resource Owner Grant Type
。
Assuming that I'm all set, I tried to get an access token using this URL: 假设我已经完成设置,我尝试使用此URL获取访问令牌:
https://login.microsoftonline.com/substitute-with-tenant-directory-id/oauth2/v2.0/token 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. 接下来,我尝试访问我需要的特定API。 Here is the URL:
这是URL:
https://graph.microsoft.com/v1.0/me/calendar/calendarView?startDateTime=2018-08-01T00:00:00.0000000&endDateTime=2018-08-31T23:59:59.0000000 https://graph.microsoft.com/v1.0/me/calendar/calendarView?startDateTime=2018-08-01T00:00:00.0000000&endDateTime=2018-08-31T23:59:59.0000000
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. 我还尝试用“users / substitute-with-user-id”替换URL中的“我”部分,但不幸的是我收到了错误。 Below is the screen capture.
下面是截屏。
I'm stuck because the response says "Unknown Error". 我被卡住,因为响应显示“未知错误”。 Does anybody know what I am missing here?
有人知道我在这里缺少什么吗?
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.
如果要加载其他用户的事件,可以使用仅限app的令牌。 Refer to https://developer.microsoft.com/en-us/graph/docs/concepts/auth_v2_service to know how to get app-only token.
请参阅https://developer.microsoft.com/en-us/graph/docs/concepts/auth_v2_service以了解如何获取仅限app的令牌。
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. 我最近通过邮递员按照本博客上给出的步骤调用了图谱API,我认为问题是你没有在正文中传递
Resource
。 Try to pass the Resource
in a body with value https://graph.microsoft.com
hope this will solve your issue. 尝试在值为
https://graph.microsoft.com
的正文中传递Resource
,希望这将解决您的问题。
Below things worked for me: 以下事情对我有用:
https://blogs.msdn.microsoft.com/softwaresimian/2017/10/05/using-postman-to-call-the-graph-api-using-azure-active-directory-aad/ https://blogs.msdn.microsoft.com/softwaresimian/2017/10/05/using-postman-to-call-the-graph-api-using-azure-active-directory-aad/
1) Create a access token from Authorization tab, select the type as OAuth 2.0 and click on GET NEW ACCESS TOKEN. 1)从授权选项卡创建访问令牌,选择类型为OAuth 2.0,然后单击GET NEW ACCESS TOKEN。
2) Enter the details like below: 2)输入如下详细信息:
Auth URL : https://login.windows.net/common/oauth2/authorize?resource=https://outlook.office.com 验证URL: https : //login.windows.net/common/oauth2/authorize? resources = https://outlook.office.com
Access Token URL : https://login.microsoftonline.com/common/oauth2/token 访问令牌URL: https : //login.microsoftonline.com/common/oauth2/token
Client ID: your application id 客户端ID:您的应用程序ID
Secret: secret set while app registration. 秘密:app注册时的秘密设置。
3) It will authenticate and token will be created. 3)它将进行身份验证并创建令牌。
4) Select Add token to Header and click on Use Token button. 4)选择Add token to Header并单击Use Token按钮。
5) In Body tab select x-www-form. 5)在Body选项卡中选择x-www-form。
6) In Header tab it should look like below: 6)在标题选项卡中,它应如下所示:
Content-Type : application/x-www-form-urlencoded 内容类型:application / x-www-form-urlencoded
Authorization : Bearer (your token generated automatically). 授权:承载(您的令牌自动生成)。
7) Perform POST Operation. 7)执行POST操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.