首页 文章

从Microsoft Graph Api访问组时出现问题

提问于
浏览
8

我试图从Microsoft Graph API访问加入的组,我已经完成了Azure AD身份验证并能够获得所需的访问令牌 .

当我从SharePoint OData endpoints 读取数据但是我无法访问URL时,访问令牌正在工作

https://graph.microsoft.com/beta/me/joinedTeams

我试图使用PostMan客户端访问它,它给了我错误

{
  "error": {
    "code": "AuthenticationError",
    "message": "Error authenticating with resource.",
    "innerError": {
      "request-id": "ef4be9c8-27c7-40e7-8157-c08848f5132f",
      "date": "2018-03-13T09:46:11"
    }
  }
}

当我尝试使用javascript代码访问此URL时,我得到了不同的错误

{
  "error": {
    "code": "BadRequest",
    "message": "Invalid version",
    "innerError": {
      "request-id": "51113cc5-2963-4e0f-bf70-6e080a8f5671",
      "date": "2018-03-13T09:29:18"
    }
  }
}

我尝试了不同的权限集,即使有行政访问但没有运气 .

我也尝试过访问

https://graph.microsoft.com/beta/me/

它在PostMan客户端工作,但不在JavaScript中工作(我得到了同样的错误) .

Tere是我用来发送请求的标头

var header = {
  Authorization: "Bearer <ACCESS_TOKEN>",
  Accept: "application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false"
};

任何人都可以建议我错过了什么或我应该使用什么权限?

这些权限需要管理员同意,这些权限是否正确?

enter image description here

Update 2 我尝试使用管理员同意,授予应用程序所有必需的权限(AD应用程序) . 以下是从jwt.io中提取的范围数据

"scp": "email Group.Read.All Group.ReadWrite.All openid User.Read User.Read.All User.ReadBasic.All User.ReadWrite.All"
    "aud": "https://graph.microsoft.com/"

我正在使用具有所有权限的管理员帐户 . 但没有运气,我仍然得到 "Error authenticating with resource." 但使用令牌我可以访问URL

https://graph.microsoft.com/v1.0/me

作为回应,我收到了管理员的所有细节

我试着阅读所有可用的文档,但没有运气

2 回答

  • 1

    我有同样的问题,并设法通过在请求访问令牌时从资源参数中删除尾随的“ / ”来使其工作 .

    所以在我的情况下资源

    https://graph.microsoft.com/ 应写成 https://graph.microsoft.com

  • 1

    您的 getAuthenticationHeader 方法正在调用错误的 endpoints :

    https://login.windows.net/advaiya.com/oauth2/token?api-version=1.0
    

    您应该将_2577427发给:

    https://login.microsoftonline.com/advaiya.com/oauth2/token
    

    你也发送了 &redirect_uri=<URL> . 在检索Id令牌时,此值需要与您传递给 https://login.microsoftonline.com/advaiya.com/oauth2/authorizeredirect_uri 匹配 .

相关问题