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

Issue while accessing Groups from Microsoft Graph Api

我正在尝试从 Microsoft Graph API 访问已加入的群组, 我已完成 Azure AD 身份验证并能够获得所需的访问令牌。

当我从 SharePoint OData 端点读取数据但我无法访问 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 中不工作(我遇到了同样的错误)。

这是我用来发送请求

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

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

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

更新 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

作为回应,我得到了 Admin

的所有详细信息

我试图阅读所有可用的文档,但没有成功

您的 getAuthenticationHeader 方法调用了错误的端点:

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

您应该将 HTTP POST 发给:

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

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

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

所以在我的例子中,资源

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