我正在使用 Micrsoft Graph API 以编程方式注册客户端应用程序、资源服务器并将角色从资源服务器分配给客户端应用程序。以下是遵循的步骤:
获取访问令牌 --> https://login.windows.net/ /oauth2/token/?api-version=1.6
客户端应用注册- > https://graph.windows.net/ /applications/?api-version=1.6
客户服务负责人
在清单中使用以下应用程序角色注册资源服务器:
"appRoles": [
{
"allowedMemberTypes": [
"Application"
],
"description": "Description of Role - Resource_API_11092017",
"displayName": "Role_Resource_API_11092017",
"id": "5ff0033d-fa87-4a77-9b3d-b4b201dfc32e",
"isEnabled": true,
"value": "Read_Only_Resource_API_11092017"
}
],
Run Code Online (Sandbox Code Playgroud)资源服务器服务主体创建
为客户端应用程序分配角色。
当我尝试使用客户端应用程序的凭据获取访问令牌时,我没有在 JWT 中获得任何角色,也没有获得资源服务器的任何信息。
我什至从客户端应用程序中的门户向资源服务器的角色授予权限。但仍然没有运气。
任何帮助将不胜感激。如果您需要更多详细信息,请告诉我。
谢谢。
@2017 年 11 月 14 日更新:
请找到 JWT 的 Payload。
{
"aud": "https://xxxxx.onmicrosoft.com/Resource_API_11092017",
"iss": "https://sts.windows.net/caa4bd37-xxxx-xxxx-xxxx-bba4bd0e22a6/",
"iat": 1510679930,
"nbf": 1510679930,
"exp": 1510683830,
"aio": "Y2NgYLipff1Ghn65atEd97grbjxxxx==",
"appid": "3ec8690d-xxxx-xxxx-xxxx-739709a758cc",
"appidacr": "1",
"idp": "https://sts.windows.net/caa4bd37-xxxx-xxxx-xxxx-bba4bd0e22a6/",
"tid": "caa4bd37-xxxx-xxxx-xxxx-bba4bd0e22a6",
"ver": "1.0"
} …