图 API:scp 或角色声明需要出现在令牌中

Graph API: Either scp or roles claim need to be present in the token

我正在尝试使用 MS Graph API 从 OneDrive for Business 获取 files/folders 的列表。我已经在 Graph Explorer 中成功执行了我需要的查询,现在我将继续在我的项目中实施。

我的应用程序是一项 Windows 服务,因此我正在使用 this method

获取令牌

我已成功检索到令牌,但是当我 "GET" 这个 URL... //graph.microsoft.com/v1.0/users('someuseraccount')/drive/items/somedriveitem/microsoft.graph.createLink

...我收到错误的回复:

Either scp or roles claim need to be present in the token.

我的服务器令牌响应如下:

{
  "token_type": "Bearer",
  "expires_in": "3600",
  "scope": "Directory.AccessAsUser.All Files.Read Files.Read.Selected Files.ReadWrite Files.ReadWrite.AppFolder Files.ReadWrite.Selected profile Sites.Read.All User.Read",
  "expires_on": "1457343736",
  "not_before": "1457339836",
  "resource": "https://graph.microsoft.com",
  "access_token": "-the token-"
}

您的客户端应用程序似乎只请求了对 Microsoft Graph 的委派权限,而应为此处尝试的方案请求应用程序权限。下面是 Azure 门户中应用程序权限部分的图示。请 select 需要适当的权限并重试。