In MS Graph, some delegated permissions need "Admin Consent" and some just need user consent.
For example, the delegated permission User.Read.All
requires admin consent. But the delegated permission User.ReadBasic.All
does not need admin consent. (But it would still need user consent.)
I know that DelegatedPermissionGrant.ReadWrite.All
allows the application to grant consent on behalf of the user. But I don't know if it can grant "Admin Consent".
Can an application with DelegatedPermissionGrant.ReadWrite.All
grant "Admin Consent"?
Yes, DelegatedPermissionGrant.ReadWrite.All
allows a principal to grant admin consent for Delegated
permissions only
AppRoleAssignment.ReadWrite.All
allows a principal to grant admin consent for Application
permissions
There are examples on how to do so with the MS Graph API and MS Graph PowerShell here
MS Graph PowerShell Example
# The object ID of your Enterprise Application
$servicePrincipalObjectId = ""
# This is the object ID of the Enterprise Application for Microsoft Graph
$graphId = Get-MgServicePrincipal -Filter "displayName eq 'Microsoft Graph'" | Select-Object -ExpandProperty Id
# Permissions to grant consent to, space separated
$scopes = "User.Read.All Directory.Read.All"
$params = @{
ClientId = $servicePrincipalObjectId
ConsentType = "AllPrincipals"
ResourceId = $graphId
Scope = $scopes
}
New-MgOauth2PermissionGrant -BodyParameter $params
Before
After