简体   繁体   English

获取Microsoft Graph API的访问令牌

[英]Getting the access token for Microsoft Graph API

I'm trying to get the access token for the Microsoft Graph API in order to access a SharePoint document library. 我正在尝试获取Microsoft Graph API的访问令牌以访问SharePoint文档库。 My application is a windows service, hence I'm following the procedure described here . 我的应用程序是一个Windows服务,因此我遵循这里描述的过程。

But when I try to get the access token, the response that I get doesn't have the scope value. 但是当我尝试获取访问令牌时,我得到的响应没有范围值。 Below is my response: 以下是我的回复:

{
  "token_type": "Bearer",
  "expires_in": "3600",
  "expires_on":"1492452559",
  "not_before": "1492448659",
  "resource": "https://graph.microsoft.com",
  "access_token": "Token"
}

Because of this when I try to query the Graph API with this access token, I'm getting an error saying: Either scp or roles claim need to be present in the token 因此,当我尝试使用此访问令牌查询Graph API时,我收到一条错误消息: scp或角色声明需要出现在令牌中

Can someone please help me on how to get this working? 有人可以帮助我如何使这个工作? Thanks in advance. 提前致谢。

That seems your client application hasn't set the appropriate app permissions when using client credential flow , below is an illustration of application permissions section in Azure AD classic portal. 这似乎是您的客户端应用程序在使用客户端凭据流时未设置适当的应用程序权限,下面是Azure AD经典门户中的应用程序权限部分的说明。 Please select appropriate permissions needed and retry : 请选择所需的适当权限并重试: 在此输入图像描述

And in addition , when using client credential flow to get the access token , you could check the roles claims in access token(that is the way to check the app permission, not in token response) , using a tool like http://jwt.calebb.net/ to decode the access token and check the app permissions : 此外,当使用客户端凭据流来获取访问令牌时,您可以使用http:// jwt等工具检查访问令牌中的roles声明(这是检查应用程序权限的方式,而不是在令牌响应中) .calebb.net /解码访问令牌并检查应用权限: 在此输入图像描述

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

相关问题 Microsoft Graph API:如何在不使用浏览器的情况下获取访问令牌 - Microsoft Graph API: how to get access token without browser Microsoft Graph API在哪里使用Azure生成的令牌? - Microsoft Graph API where use token generated by azure? C# - Microsoft Graph API - 从自定义列表中获取图片 - C# - Microsoft Graph API - Getting Pictures from Customlist 如何通过Microsoft Graph API访问Onedrive业务 - How to access Onedrive Business via Microsoft Graph API 通过 Microsoft Graph API 访问文档库站点的文件 - Access files of Document Library site through Microsoft Graph API 通过 ID 获取站点时出现 Microsoft Graph API serviceNotAvailable 错误 - Microsoft Graph API serviceNotAvailable error when getting site by ID 未经授权:访问被拒绝,因为凭证无效。 用于共享点的 Microsoft Graph API - Unauthorized: Access is denied due to invalid credentials . Microsoft Graph API for sharepoint 如何通过仅 SharePoint 应用程序注册访问 Microsoft Graph API - How to access Microsoft Graph API with a SharePoint App-Only registration 从 Sharepoint 获取 Graph API 有效访问令牌 在线登录 - Get Graph API valid access token from Sharepoint Online login Microsoft Graph API 超时异常 - Microsoft Graph API timeout exception
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM