Reputation: 1
I am trying to use Microsoft Partner Center APIs. Tried with below PowerShell script but getting error. Due to this, we are unable to use Microsoft Partner Center APIs so looking for help to fix this issue.
Sample Code:
$AzureADtenant = "ABC.onmicrosoft.com"
$AzureADtenantId = "xxxx"
$ClientId = "yyyy"
$ClientSecret = "zzzzz"
$resource = "https://partner.microsoft.com"
$requestAccessTokenUri = "https://login.microsoftonline.com/$AzureADtenantid/oauth2/token"
$body = "grant_type=client_credentials&client_id=$ClientId&client_secret=$ClientSecret&resource=$resource"
$accessToken = Invoke-RestMethod -Method Post -Uri $requestAccessTokenUri -Body $body -ContentType 'application/x-www-form-urlencoded'
Error:
Invoke-RestMethod : {"error":"server_error","error_description":"AADSTS50000: There was an error issuing a token or an issue with our sign-in service.\r\nTrace ID: 60c1365f-be7f-472a-87c8-fd03aa9b4a02\r\nCorrelation ID:
d5422741-088d-4cad-9da8-fd6c4486fc94\r\nTimestamp: 2023-10-19 14:26:22Z","error_codes":[50000],"timestamp":"2023-10-19
14:26:22Z","trace_id":"60c1365f-be7f-472a-87c8-fd03aa9b4a02","correlation_id":"d5422741-088d-4cad-9da8-fd6c4486fc94","error_uri":"https://login.microsoftonline.com/error?code=50000"}
At line:12 char:16
+ ... cessToken = Invoke-RestMethod -Method Post -Uri $requestAccessTokenUr ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodComm
Upvotes: 0
Views: 32