Skip to content

Commit 9494c03

Browse files
authored
Merge pull request MicrosoftDocs#231 from msewaweru/delegated-perms-tutorial-update
Made updates to the article
2 parents e37a6da + 363683e commit 9494c03

File tree

2 files changed

+49
-18
lines changed

2 files changed

+49
-18
lines changed

microsoftgraph/docs-conceptual/tutorial-grant-app-only-api-permissions.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
---
22
title: "Grant application permissions programmatically in Azure AD"
3-
description: "Learn how to grant app-only permissions programmatically in Azure AD using Microsoft Graph PowerShell"
3+
description: "Learn how to grant and revoke app-only permissions programmatically in Azure AD using Microsoft Graph PowerShell"
44
ms.topic: tutorial
5-
ms.date: 12/07/2022
5+
ms.date: 03/17/2022
66
author: msewaweru
77
manager: CelesteDG
88
ms.author: eunicewaweru
99
ms.reviewer: jawoods, phsignor
1010
---
1111

12-
# Tutorial: Grant app roles in Azure AD
12+
# Tutorial: Grant and revoke app roles in Azure AD
1313

1414
When you grant API permissions to a client app in Azure AD, the permission grants are recorded as objects that can be accessed, updated, or deleted like other objects. Using Microsoft Graph PowerShell cmdlets to directly create permission grants is a programmatic alternative to [interactive consent](/azure/active-directory/manage-apps/consent-and-permissions-overview). This can be useful for automation scenarios, bulk management, or other custom operations in your organization.
1515

@@ -24,7 +24,7 @@ To successfully complete this tutorial, make sure you have the required prerequi
2424

2525
1. A working Azure AD tenant.
2626
1. Microsoft Graph PowerShell SDK is installed. Follow the [Install the Microsoft Graph PowerShell SDK](installation.md) guide to install the SDK.
27-
1. Microsoft Graph PowerShell using a global administrator role and the appropriate permissions. For this tutorial, the `Application.Read.All` and `AppRoleAssignment.ReadWrite.All` delegated permissions are required. To set the permissions in Microsoft Graph PowerShell, run:
27+
1. Microsoft Graph PowerShell using a user with privileges to create applications in the tenant and the appropriate permissions. For this tutorial, the `Application.Read.All` and `AppRoleAssignment.ReadWrite.All` delegated permissions are required. To set the permissions in Microsoft Graph PowerShell, run:
2828

2929
```powershell
3030
Connect-MgGraph -Scopes "Application.ReadWrite.All", "AppRoleAssignment.ReadWrite.All"
@@ -101,7 +101,7 @@ AppId : 05210c44-437f-4a40-bd38-b5b4eaf251ef
101101
SignInAudience : AzureADandPersonalMicrosoftAccount
102102
```
103103

104-
## Step 3: Assign an app role to the client service principal
104+
## Step 3: Assign an app role to the client enterprise application
105105

106106
In this step, you'll assign an app role exposed by your resource app to the service principal we created in step 2. To create an app role assignment, you'll need the following information:
107107

@@ -132,7 +132,7 @@ PrincipalType : ServicePrincipal
132132
ResourceDisplayName : Microsoft Graph
133133
```
134134

135-
## Step 4: Revoke an app role assignment from a client service principal
135+
## Step 4: Revoke an app role assignment from a client enterprise application
136136

137137
To revoke the app roles assigned in step 3, run:
138138

@@ -143,3 +143,4 @@ Remove-MgServicePrincipalAppRoleAssignedTo -ServicePrincipalId '22c1770d-30df-49
143143
## See also
144144

145145
- [Tutorial: Grant delegated permissions programmatically in Azure AD](tutorial-grant-delegated-api-permissions.md)
146+
- [Grant or revoke API permissions using Microsoft Graph](/graph/permissions-grant-via-msgraph?branch=pr-en-us-20614&tabs=http&pivots=grant-application-permissions)

microsoftgraph/docs-conceptual/tutorial-grant-delegated-api-permissions.md

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
---
2-
title: "Grant delegated permissions programmatically in Azure AD"
3-
description: "Learn how to grant delegated permissions programmatically in Azure AD using Microsoft Graph PowerShell"
2+
title: "Grant and revoke delegated permissions programmatically in Azure AD"
3+
description: "Learn how to grant and revoke delegated permissions programmatically in Azure AD using Microsoft Graph PowerShell"
44
ms.topic: tutorial
5-
ms.date: 12/07/2022
5+
ms.date: 03/17/2023
66
author: msewaweru
77
manager: CelesteDG
88
ms.author: eunicewaweru
99
ms.reviewer: jawoods, phsignor
1010
---
1111

12-
# Tutorial: Grant delegated permissions in Azure AD
12+
# Tutorial: Grant and revoke delegated permissions in Azure AD
1313

1414
When you grant API permissions to a client app in Azure AD, the permission grants are recorded as objects that can be accessed, updated, or deleted like other objects. Using Microsoft Graph PowerShell cmdlets to directly create permission grants is a programmatic alternative to [interactive consent](/azure/active-directory/manage-apps/consent-and-permissions-overview). This can be useful for automation scenarios, bulk management, or other custom operations in your organization.
1515

1616
>[!Caution]
1717
>Be Careful! Permissions created programmatically are not subject to review or confirmation. They take effect immediately.
1818
19-
In this tutorial, you'll grant delegated permissions that are exposed by an API to an app. Delegated permissions, also called scopes or OAuth2 permissions, allow an app to call an API on behalf of a signed-in user.
19+
In this tutorial, you'll grant and revoke delegated permissions that are exposed by an API to an app. Delegated permissions, also called scopes or OAuth2 permissions, allow an app to call an API on behalf of a signed-in user.
2020

2121
## Prerequisites
2222

2323
To successfully complete this tutorial, make sure you have the required prerequisites:
2424

2525
1. A working Azure AD tenant.
2626
1. Microsoft Graph PowerShell SDK is installed. Follow the [Install the Microsoft Graph PowerShell SDK](installation.md) guide to install the SDK.
27-
1. Microsoft Graph PowerShell using a global administrator role and the appropriate permissions. For this tutorial, the `Application.Read.All` and `DelegatedPermissionGrant.ReadWrite.All` delegated permissions are required. To set the permissions in Microsoft Graph PowerShell, run:
27+
1. Microsoft Graph PowerShell using a user with privileges to create applications in the tenant and the appropriate permissions. For this tutorial, the `Application.Read.All` and `DelegatedPermissionGrant.ReadWrite.All` delegated permissions are required. To set the permissions in Microsoft Graph PowerShell, run:
2828

2929
```powershell
3030
Connect-MgGraph -Scopes "Application.ReadWrite.All", "DelegatedPermissionGrant.ReadWrite.All"
@@ -35,7 +35,7 @@ To successfully complete this tutorial, make sure you have the required prerequi
3535
3636
## Step 1: Get the delegated permissions of the resource service principal
3737
38-
Before you can grant delegated permissions, you must first identify the delegated permissions to grant and the resource service principal that exposes the delegated permissions. Delegated permissions are defined in the `oauth2PermissionScopes` object of a service principal.
38+
Before you can grant delegated permissions, you must first identify the delegated permissions to grant and the resource service principal that exposes the delegated permissions. Delegated permissions are defined in the `oauth2PermissionScopes` object of a service principal.
3939
4040
In this article, you'll use the `Microsoft Graph` service principal in the tenant as your resource service principal.
4141
@@ -107,7 +107,7 @@ AppId : 05210c44-437f-4a40-bd38-b5b4eaf251ef
107107
SignInAudience : AzureADandPersonalMicrosoftAccount
108108
```
109109

110-
## Step 3: Grant delegated permission to the client service principal
110+
## Step 3: Grant delegated permissions to the client enterprise application
111111

112112
To create a delegated permission grant, you'll need the following information:
113113

@@ -139,10 +139,25 @@ PrincipalId :
139139
ResourceId : a67ad0d0-a7d1-4adb-8cd9-bcdd0c866d3c
140140
Scope : Group.Read.All
141141
```
142+
To confirm the delegated permissions assigned to the service principal on behalf of the user, you run the following command.
142143

143-
### Step 4: Assign more or revoke delegated permissions to the service principal
144+
```powershell
145+
Get-MgOauth2PermissionGrant -Filter "clientId eq '22c1770d-30df-49e7-a763-f39d2ef9b369' and consentType eq 'AllPrincipals'"
146+
```
147+
148+
```Output
149+
ClientId : 22c1770d-30df-49e7-a763-f39d2ef9b369
150+
ConsentType : AllPrincipals
151+
Id : DXfBIt8w50mnY_OdLvmzadDQeqbRp9tKjNm83QyGbTw
152+
PrincipalId :
153+
ResourceId : 2cab1707-656d-40cc-8522-3178a184e03d
154+
Scope : Group.Read.All,User.Read.All
155+
AdditionalProperties : {}
156+
```
157+
158+
### Step 4: Grant more delegated permissions to the enterprise application
144159

145-
You can add more or reduce scopes from an existing oauth2PermissionGrant object.
160+
You can add more permissions to an existing oauth2PermissionGrant object.
146161

147162
To add the `User.Read.All` scope to the oauthPermissionGrant object, run:
148163

@@ -154,14 +169,29 @@ $params = @{
154169
Update-MgOauth2PermissionGrant -OAuth2PermissionGrantId 'DXfBIt8w50mnY_OdLvmzadDQeqbRp9tKjNm83QyGbTw' -BodyParameter $params
155170
```
156171

157-
To revoke a delegated permission grant, run:
172+
### Step 5: Revoke delegated permissions granted to an enterprise application
173+
174+
If a service principal has been granted multiple delegated permission grants, you can choose to revok either specific gants or all grants.
175+
176+
- To revoke one or more grants, update oauthPermissionGrant object and specify only the delegated permissions to retain in the **scope** parameter. For example, to revoke the `User.read.All` permission, run:
177+
178+
```powershell
179+
$params = @{
180+
Scope = "Group.Read.All"
181+
}
182+
183+
Update-MgOauth2PermissionGrant -OAuth2PermissionGrantId 'DXfBIt8w50mnY_OdLvmzadDQeqbRp9tKjNm83QyGbTw' -BodyParameter $params
184+
```
185+
186+
- To revoke all grants, use `Remove-MgOauth2PermissionGrant`.
158187

159188
```powershell
160-
Remove-MgOauth2PermissionGrant -OAuth2PermissionGrantId 'DXfBIt8w50mnY_OdLvmzaQcXqyxtZcxAhSIxeKGE4D0'
189+
Remove-MgOauth2PermissionGrant -OAuth2PermissionGrantId 'DXfBIt8w50mnY_OdLvmzadDQeqbRp9tKjNm83QyGbTw'
161190
```
162191

163192
When a delegated permission grant is deleted, the access it granted is revoked. Existing access tokens will continue to be valid for their lifetime, but new access tokens will not be granted for the delegated permissions identified in the deleted oAuth2PermissionGrant.
164193

165194
## See also
166195

167196
- [Tutorial: Grant application permissions programmatically in Azure AD](tutorial-grant-app-only-api-permissions.md)
197+
- [Grant or revoke API permissions using Microsoft Graph](/graph/permissions-grant-via-msgraph?tabs=http&pivots=grant-delegated-permissions)

0 commit comments

Comments
 (0)