简体   繁体   English

图Api - 401未经授权

[英]Graph Api - 401 Unauthorised

just started in the graph/office API and wow is it a minefield! 刚刚开始使用图形/办公室API,哇,这是一个雷区!

Just wondering if anyone can give me any advice? 只是想知道是否有人可以给我任何建议? I am getting a 401 when I attempt to contact https://graph.microsoft.com/beta/me/files . 当我尝试联系https://graph.microsoft.com/beta/me/files时,我得到401。

My JWT is as follows: 我的JWT如下:

{
  "aud": "https://graph.windows.net/",
  "iss": "https://sts.windows.net/916970f4-e570-4036-a353-8ae647af1d3e/",
  "iat": 1444794383,
  "nbf": 1444794383,
  "exp": 1444798283,
  "ver": "1.0",
  "tid": "916970f4-e570-4036-a353-8ae647af1d3e",
  "oid": "c454b826-612f-4525-8995-87f1a24dc3df",
  "sub": "c454b826-612f-4525-8995-87f1a24dc3df",
  "idp": "https://sts.windows.net/916970f4-e570-4036-a353-8ae647af1d3e/",
  "appid": "568d0906-4131-4b97-8b08-9efdbe1636c4",
  "appidacr": "1"
}

My tokens are aquired in a rather odd way... I have a web project azure AD, who's token is used to aquire a web api Azure Ad token, then that Token is used to produce the graph api jwt as shown above. 我的令牌以一种相当奇怪的方式被获取...我有一个web项目azure AD,谁的令牌用于获取web api Azure Ad令牌,然后该令牌用于生成图api jwt,如上所示。

Heres how it woks: 下面是怎么回事:

在此输入图像描述

Sorry you are running in to issues here. 对不起,您在这里遇到问题。 Two things... 两件事情...

  1. You are getting a 401 because the audience of the token is for Azure AD Graph API, but it needs to be for the Office 365 unified API, since these are 2 differently APIs. 您获得的是401,因为令牌的受众是针对Azure AD Graph API的,但它需要用于Office 365统一API,因为这些是两种不同的API。 To get a token for the unified API, you need to specify the resource in your token acquisition request as https://graph.microsoft.com . 要获取统一API的令牌,您需要将令牌获取请求中的资源指定为https://graph.microsoft.com Basically tokens cannot be interchangeably used against different services - tokens are audience/resource specific. 基本上,令牌不能互换用于不同的服务 - 令牌是受众/资源特定的。 We should have some extra information and samples for this here http://dev.office.com/unifiedapis . 我们应该在http://dev.office.com/unifiedapis上提供一些额外的信息和样本。
  2. The Office 365 unified API ONLY supports the code flows (aka app+user or delegated flows). Office 365统一API仅支持代码流(即app +用户或委派流)。 Your token appears to be a client credentials flow token (ie app only - no user context). 您的令牌似乎是客户端凭据流令牌(即仅限应用程序 - 无用户上下文)。 This kind of token/flow is not possible yet with the unified api, but it is something we are working on. 使用统一的api这种令牌/流是不可能的,但这是我们正在努力的事情。 Stay tuned. 敬请关注。

Hope this helps, 希望这可以帮助,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM