Forum Discussion
Accessing app centric permission via API
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?- Nivedipa-MSFTJun 19, 2024
Microsoft
LarsSchw - Have you verified the AppManagementPolicyId parameter?