将角色添加到应用程序注册并将用户分配给角色可以采用Microsoft Graph API来完成。
代码示例:
POST https://graph.microsoft.com/v1.0/roles
{ "displayName": "Manager", "description": "Can manage other users", "roleTemplateId": "b24988ac-6180-42a0-ab88-20f7382dd24c" }
代码示例:
POST https://graph.microsoft.com/v1.0/servicePrincipals/{id}/appRoleAssignments
{ "appRoleId": "role id", "principalId": "user id", "resourceId": "app id" }
代码示例:
POST https://graph.microsoft.com/v1.0/servicePrincipals/{id}/appRoleAssignedTo
{ "appRoleId": "role id", "principalId": "user id", "resourceId": "app id" }