Skip to content

Commit c7408ca

Browse files
authored
Merge pull request #194180 from psignoret/patch-19
Fixing spacing and pre-requisites
2 parents 944f765 + b2e872b commit c7408ca

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

articles/active-directory/manage-apps/grant-consent-single-user.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ When a user grants consent on his or her own behalf, the following events occur:
3131

3232
To grant consent to an application on behalf of one user, you need:
3333

34-
- A user account. If you don't already have one, you can [create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
35-
- A Global Administrator or Privileged Administrator role.
34+
- A user account with Global Administrator, Application Administrator, or Cloud Application Administrator
3635

3736
## Grant consent on behalf of a single user
3837

@@ -48,16 +47,20 @@ For this example, we'll use [Microsoft Graph PowerShell](/graph/powershell/get-s
4847
# The app for which consent is being granted. In this example, we're granting access
4948
# to Microsoft Graph Explorer, an application published by Microsoft.
5049
$clientAppId = "de8bc8b5-d9f9-48b1-a8ad-b748da725064" # Microsoft Graph Explorer
50+
5151
# The API to which access will be granted. Microsoft Graph Explorer makes API
5252
# requests to the Microsoft Graph API, so we'll use that here.
5353
$resourceAppId = "00000003-0000-0000-c000-000000000000" # Microsoft Graph API
54+
5455
# The permissions to grant. Here we're including "openid", "profile", "User.Read"
5556
# and "offline_access" (for basic sign-in), as well as "User.ReadBasic.All" (for
5657
# reading other users' basic profile).
5758
$permissions = @("openid", "profile", "offline_access", "User.Read", "User.ReadBasic.All")
59+
5860
# The user on behalf of whom access will be granted. The app will be able to access
5961
# the API on behalf of this user.
6062
$userUpnOrId = "[email protected]"
63+
6164
# Step 0. Connect to Microsoft Graph PowerShell. We need User.ReadBasic.All to get
6265
# users' IDs, Application.ReadWrite.All to list and create service principals,
6366
# DelegatedPermissionGrant.ReadWrite.All to create delegated permission grants,
@@ -66,12 +69,14 @@ $userUpnOrId = "[email protected]"
6669
Connect-MgGraph -Scopes ("User.ReadBasic.All Application.ReadWrite.All " `
6770
+ "DelegatedPermissionGrant.ReadWrite.All " `
6871
+ "AppRoleAssignment.ReadWrite.All")
72+
6973
# Step 1. Check if a service principal exists for the client application.
7074
# If one does not exist, create it.
7175
$clientSp = Get-MgServicePrincipal -Filter "appId eq '$($clientAppId)'"
7276
if (-not $clientSp) {
7377
$clientSp = New-MgServicePrincipal -AppId $clientAppId
7478
}
79+
7580
# Step 2. Create a delegated permission that grants the client app access to the
7681
# API, on behalf of the user. (This example assumes that an existing delegated
7782
# permission grant does not already exist, in which case it would be necessary
@@ -84,6 +89,7 @@ $grant = New-MgOauth2PermissionGrant -ResourceId $resourceSp.Id `
8489
-ClientId $clientSp.Id `
8590
-ConsentType "Principal" `
8691
-PrincipalId $user.Id
92+
8793
# Step 3. Assign the app to the user. This ensures that the user can sign in if assignment
8894
# is required, and ensures that the app shows up under the user's My Apps.
8995
if ($clientSp.AppRoles | ? { $_.AllowedMemberTypes -contains "User" }) {

0 commit comments

Comments
 (0)