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

Ganesh Kumar Pandithurai 20 Reputation points
2023-10-19T14:35:17.8466667+00:00

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:

Code:

$AzureADtenant = "XeroxDevelopment.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.InvokeRestMethodCommand
Microsoft Partner Center API
Microsoft Partner Center API
Microsoft Partner Center: A Microsoft website for partners that provides access to product support, a partner community, and other partner services.API: A software intermediary that allows two applications to interact with each other.
317 questions
{count} votes