Error:invalid_client getting the Client Credentials from Orchestrator API

Hi,

I followed the UiPath documentation from these two links:

I created an external application in my community orchestrator with Application scope and type is Confidential. Now I’m trying to generate access token using client credentials method.

I’m using Http request activity in UiPath. I gave
Endpoint - “https://cloud.uipath.com/identity_/connect/token
Method: Post
body -
{
“grant_type”: “client_credentials”,
“client_id”: “{my app_id}”,
“client_secret”: “{my app_secret}”,
“scope”: “OR.Folders.Read OR.Jobs.Read OR.Queues.Read”
}

Headers:
image

BodyFormat(property in http request activity) - application/json

I’m still getting the “invalid_client” error.

I’ve seen this post Error:invalid_client getting the Client Credentials - #13 by Madan_Ongole , so added Authorization header.

Tried removing authorization header, I’m still getting “invalid_client” error

If I remove Content-Type header, I’m still getting “invalid_request” error.

If I try like this in powershell, then I’m getting bad request error:

$body = (Get-Content -Path “A:\UiPath\UIpathWorkspace\PracticeWorkflowsPersonal\AccessTokenRequestBody.txt” | Out-String | ConvertTo-Json)
$url = “https://cloud.uipath.com/identity_/connect/token
$headers = @{
‘ContentType’ = ‘application/x-www-form-urlencoded’
‘Authorization’ = ‘Bearer Token’
}
Invoke-RestMethod -Body $body -Method Post -Uri $url -Headers $headers

Looks like something is misssing in UiPath documentation about using Orchestrator API to generate access token. Can anyone please help?

@Forum_Staff @ppr @Madan_Ongole @FoxHere @qbrandon

Just to be sure: can you double check that when you added scopes you chose “Application Scope” and not “User Scope”?
Also, BodyFormat(property in http request activity) - application/x-www-form-urlencoded please (no need to set any header)

HI @qbrandon

I’ve chosen “Application Scope”.

ok. I’ll update the BodyFormat, I’ll test it and get back.

@qbrandon

I’ve updated the BodyFormat property and also removed headers. But still I’m getting “Invalid client” error

@Surya_Narayana_Korivipadu

Can you check the Authorization Header, I believe it should be "Bearer "+Token
Where Token is a variable which has the access token


Hope this may help you

Thanks

I am using the UiPath.Web.Activities package 1.7.0
The HTTP Request is configured for POST, with the endpoint set to “https://cloud.uipath.com/identity_/connect/token”, no attachment, no header, no body set. Body format set to application/x-www-form-urlencoded, and parameters configured as show at the bottom of the screenshot.
As mentioned before, the external application was configured as confidential, and with Application Scopes only.

4 Likes

We are doing this API request to get access token.

How can I pass access token without knowing it?

1 Like

I’m passing these parameters in the body json. I’ll try passing them like you in parameters input.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.