Forum Discussion
LarsSchw
Jun 12, 2024Copper Contributor
Accessing app centric permission via API
Hi, is there any way to access (get/set) app centric permissions from GraphAPI or any other API? Our usecase is that we want to set the configuration programatically and also assign groups to spe...
Nivedipa-MSFT
Microsoft
Jun 13, 2024LarsSchw -
We can set app management policies using the Graph API. You can check the following document for this.
appManagementPolicy resource type - Microsoft Graph v1.0 | Microsoft Learn
Please let us know if this is what you are looking for or if it is not exactly what you want?
- Nivedipa-MSFTJun 17, 2024
Microsoft
LarsSchw - Could you please confirm is your issue resolved or are you still looking for any help?- LarsSchwJun 17, 2024Copper Contributor
Nivedipa-MSFTUnfortunately, this didn't work. Trying to get all app policies using Get-MgPolicyAppManagementPolicy gives an empty list. Although I configured access for a security group using app-centric management in Teams Admin (beware, permission policies are no longer used in the Teams Admin UI; groups have been assigned under "Manage Apps").
This is the code I used:
$body = @{
Grant_Type = "client_credentials"
Scope = "https://graph.microsoft.com/.default"
Client_Id = $appid
Client_Secret = $secret
}
$connection = Invoke-RestMethod `
-Uri https://login.microsoftonline.com/$tenantid/oauth2/v2.0/token `
-Method POST `
-Body $body
$token = $connection.access_token | ConvertTo-SecureString -AsPlainText -Force
Connect-MgGraph -AccessToken $token$catalog = Get-MgAppCatalogTeamApp -ExpandProperty "AppDefinitions" -Property "AppDefinitions"
$catalog | ConvertTo-Json -Depth 50 | Out-File -FilePath c:\temp\appcatalog.json$policy = Get-MgPolicyAppManagementPolicy
$policy | ConvertTo-Json -Depth 50 | Out-File -FilePath c:\temp\appPolicy.json- Nivedipa-MSFTJun 18, 2024
Microsoft
LarsSchw - The Get-MgPolicyAppManagementPolicy cmdlet requires an -AppManagementPolicyId parameter. Ensure that you're providing the correct ID when calling the cmdlet?