Forum Discussion
Jainvat
Jan 13, 2025Copper Contributor
Authentication issue while using Client Credential through Oauth2.0
Hi Community Hope you are doing well. I am unable to authenticate to our registered app in azure. I am looking to test the get/users graph api using insomnia (similar tool as postman). During ...
RalfLueders
Mar 06, 2025Copper Contributor
I'm using powershell to access Graph.
I assigned only application permissions to the Entra registered App (not delegated permissions!)
So when connecting to Graph, no scope is needed.
But it only worked when I encrypted the access token:
You could test your App registration with powershell:
$body = @{
grant_type = "client_credentials"
scope = "https://graph.microsoft.com/.default"
client_id = $clientId
client_secret = $clientSecret
}
$response = Invoke-RestMethod -Uri "https://login.microsoftonline.com/$tenantId/oauth2/v2.0/token" -Method Post -Body $body
$mgAccessToken = $response.access_token
$mgSecureAccessToken = ConvertTo-SecureString $mgaccessToken -AsPlainText -Force
$mg = Connect-MgGraph -AccessToken $mgSecureAccessToken