We are developing an Office Add-in that authenticates with an organisational account to Azure AD. The Add-in needs administrative consent. So if an administrator is logged o
Yes, you can do this. You'll want to call this MS Graph endpoint, and inspect the oAuth2PermissionGrant object for the consentType
field being set to AllPrincipals
.
Using the Microsoft Graph, you can identify if admin consent was granted. When Admin Consent is granted, there are OAuth2.0 permission grants written on the app.
Inside each permission grant, there's a field that indicates the permission level of the grant. For Admin Consent, you would be looking for AllPrincipals
.
App Role: Directory.Read.All
& Directory.ReadWrite.All
Delegated Permission: Diretory.Read.All
, Directory.ReadWrite.All
, or Directory.AccessAsUser.All
in order of least to most privileged.
This returns back an oAuth2PermissionGrant object with the details you're looking for.
consentType
field. You may need to enumerate all the grants looking for the value AllPrincipals
.IMHO, the custom implementation would be a better choice for your usecase
The steps could be the following
After the user approves of his admin access, we typically get the status in the response back from Azure AD like the one below,
GET http://localhost/myapp/permissions?tenant=a8990e1f-ff32-408a-9f8e-78d3b9139b95&state=state=12345&admin_consent=True
The App now stores the admin consent grant status in the DB.
In case of reading more about the steps, please click here