How to perform the OAuth 2.0 request in UiPath?
I am able to perform the same request in Postman using the following parameters:
I am attaching a screenshot of the parameters which I provided in Postman.
If you’re building a UiPath Robot to connect to UiPath Cloud and fetch data via APIs, you’ll need to create a Confidential application with Application scopes. Use the Client ID and Client Secret to authenticate with UiPath Cloud to obtain an access token, and make subsequent API calls using that token. Reference for authentication: Orchestrator - Accessing UiPath Resources Using External Applications
Make a HTTP POST call to the https://cloud.uipath.com/identity_/connect/token endpoint and with a request body "client_id={your_client_id}&client_secret={your_client_secret}&grant_type=client_credentials&scope={your_requested_scopes}", and the response body will include an access_token property.
Use x-www-form-urlencoded with this request body, client_id={your_client_id}&client_secret={your_client_secret}&grant_type=client_credentials&scope={your_requested_scopes}
I would like to add to this that I have been struggling all morning to get the API working, My solution was to use a Personal Access Token. This might not work for every use case… of course… but this was by far the easiest to setup. Here a little tutorial on how to fix this:
Step 1: Download the OpenAPI JSON from dataservice (Open Dataservice and click the API Access and dowload the JSON)
Step 2: Load it into your Postman
Step 3: Create a PAT with the right access to certain scopes under your name icon in Orchestrator (top right icon then preferences then Personal Access Token)
Step 4: In Postman select the request you want to send and under authorization place your PAT at the Bearer token spot (or save it in your vault and connect the variable as you should)
Step 5: Send it!!! And… Success!!!