Grant an appRoleAssignment to a group
Namespace: microsoft.graph
Important
APIs under the /beta version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported. To determine whether an API is available in v1.0, use the Version selector.
Use this API to assign an app role to a group. All direct members of the group will be considered assigned. To grant an app role assignment to a group, you need three identifiers:
- principalId: The ID of the group to which you are assigning the app role.
- resourceId: The ID of the resource servicePrincipal that has defined the app role.
- appRoleId: The ID of the appRole (defined on the resource service principal) to assign to the group.
Additional licenses might be required to use a group to manage access to applications.
Permissions
One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions.
| Permission type | Permissions (from least to most privileged) |
|---|---|
| Delegated (work or school account) | AppRoleAssignment.ReadWrite.All |
| Delegated (personal Microsoft account) | Not supported. |
| Application | AppRoleAssignment.ReadWrite.All |
HTTP request
POST /groups/{groupId}/appRoleAssignments
Note
As a best practice, we recommend creating app role assignments through the appRoleAssignedTo relationship of the resource service principal, instead of the appRoleAssignments relationship of the assigned user, group, or service principal.
Request headers
| Name | Description |
|---|---|
| Authorization | Bearer {token}. Required. |
| Content-type | application/json. Required. |
Request body
In the request body, supply a JSON representation of an appRoleAssignment object.
The following table shows the properties that are required when you create the appRoleAssignment. Specify other writable properties as necessary for your appRoleAssignment.
| Property | Type | Description |
|---|---|---|
| appRoleId | Guid | The identifier (id) for the app role which is assigned to the principal. This app role must be exposed in the appRoles property on the resource application's service principal (resourceId). If the resource application has not declared any app roles, a default app role ID of 00000000-0000-0000-0000-000000000000 can be specified to signal that the principal is assigned to the resource app without any specific app roles. |
| principalId | Guid | The unique identifier (id) for the group being granted the app role. |
| resourceId | Guid | The unique identifier (id) for the resource service principal for which the assignment is made. |
Response
If successful, this method returns a 201 Created response code and an appRoleAssignment object in the response body.
Examples
Request
Here is an example of the request. In this example, ID in the URL and value of principalId would both be the ID of the assigned group.
POST https://graph.microsoft.com/beta/groups/7679d9a4-2323-44cd-b5c2-673ec88d8b12/appRoleAssignments
Content-Type: application/json
{
"principalId": "7679d9a4-2323-44cd-b5c2-673ec88d8b12",
"resourceId": "076e8b57-bac8-49d7-9396-e3449b685055",
"appRoleId": "00000000-0000-0000-0000-000000000000"
}
Response
Here is an example of the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 201 Created
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#groups('7679d9a4-2323-44cd-b5c2-673ec88d8b12')/appRoleAssignments/$entity",
"id": "pNl5diMjzUS1wmc-yI2LEkGgWqFFrFdLhG2Ly2CysL4",
"deletedDateTime": null,
"appRoleId": "00000000-0000-0000-0000-000000000000",
"creationTimestamp": "2021-02-19T17:55:08.3369542Z",
"principalDisplayName": "Young techmakers",
"principalId": "7679d9a4-2323-44cd-b5c2-673ec88d8b12",
"principalType": "Group",
"resourceDisplayName": "Yammer",
"resourceId": "076e8b57-bac8-49d7-9396-e3449b685055"
}
Feedback
Submit and view feedback for