Hi,
I am a beginner in this, sorry in advance.
I need to get information from this URI in PowerShell: https://graph.microsoft.com/v1.0/identityGovernance/accessReviews/definitions.
I have created an application EntraID with the following permissions:
- AccessReview.ReadWrite.All
- Groups.Read.All
I have granted admin consent to the two.
I have this script:
# GET TOKEN
$uri = "https://login.microsoftonline.com/$tenantId/oauth2/v2.0/token"
$body = @{
client_id = $AppId
scope = "https://graph.microsoft.com/.default"
client_secret = $AppSecret
grant_type = "client_credentials"
}
$tokenRequest = Invoke-WebRequest -Method Post -Uri $uri -ContentType "application/x-www-form-urlencoded" -Body $body -UseBasicParsing
# Unpack Access Token
$token = ($tokenRequest.Content | ConvertFrom-Json).access_token
$Headers = @{
'Content-Type' = "application\json"
'Authorization' = "Bearer $Token"
'ConsistencyLevel' = "eventual" }
# GET DATA
$URI= "https://graph.microsoft.com/v1.0/identityGovernance/accessReviews/definitions"
Invoke-RestMethod -Headers $Headers -Uri $Uri -UseBasicParsing -Method "GET" -ContentType "application/json"
I receive a token that I can parse in jwt.ms.
I can't see the scopes or roles in this token (or at least, I can't find it).
But, for the URI I need info from,
"https://graph.microsoft.com/v1.0/identityGovernance/accessReviews/definitions"
I only receive a 403 Forbidden error...
I don't know what's wrong. Could you please help me?