How To Use UiPath External Application With User Scopes In Power Automate?

How to use UiPath External Application with User Scopes in Power Automate?

How to use UiPath External Application with User Scopes in Power Automate?

First create a new External Application is the UiPath Automation Cloud or On-Premise Orchestrator and assign the required User Scope(s) as described in the below documentation:

Add the following redirect URI in the UiPath External Application: https://global.consent.azure-apim.net/redirect


The UiPath External Application properties should look like this:

image.png

Because the HTTP request action from Power Automate does not support interactive authentication (required for User Scope), create a custom connector in Power Automate.

Below is an example on how to create a simple custom connector in Power Automate that will retrieve the Orchestrator Folders.

Note: The example is for Automation Cloud. For On-Premise Orchestrator the "Authorization URL", "Token URL" and "Refresh URL" will be slightly different. Check the article Using OAuth For External Apps for more info.

  1. Go to https://powerautomate.com and authenticate -> Select "Data -> Custom Connectors" on the left side panel, then select "New custom connector -> Create from blank"
  2. The editor will firstly display the "General" properties

Mark the "Scheme" as HTTPS and add "Host" as "cloud.uipath.com". Other properties are optional, however as a best practice it would be good to add an Icon and a description for the Custom connector.

  1. Next, configure the Security properties (here you will configure the authentication parameters)

Input the following details:

image.png

The "Authorization URL", "Token URL" and "Refresh URL" for Automation Cloud are documented Accessing UiPath Resources Using External Applications .

  1. Select "Create connector" now

Note: Although the "Redirect URL" is usually the same, double check it with the one used to register the UiPath External Application (if it is different, replace the one in the UiPath Application with the one from the custom connector).

  1. Definition blade ( add the action that is desired to be performed. In this example, use a GET query to get the folders from Orchestrator)
    1. Click on "New Action"
    2. Configure the General section:

Give it an explicit name (In this scenario, use "Get folders from Orchestrator"), a description and an Operation ID.

  1. Configure the Request section (here define the HTTP request for the action)
  • Select "Import from Sample"
  • Select the request type (in this example, GET)


Optional: After Import, further edit the parameters by selecting each of them and Edit (not needed in this example)

  1. Configure the Response section (how the action will handle the response)
    1. Select "Add default response"


  1. A sample response of this query is required. Generate it with Postman or other tools of choice by running the query used in the "Request" section

Sample payload for this example:

{
 "@odata.context": "https://cloud.uipath.com///orchestrator_/odata/$metadata#Folders",
 "@odata.count": 2,
 "value": [
   {
     "Key": "ed235fe9-a000-4460-b2d2-9db93c6bbcb2",
     "DisplayName": "Shared",
     "FullyQualifiedName": "Shared",
     "FullyQualifiedNameOrderable": "Shared",
     "Description": null,
     "ProvisionType": "Automatic",
     "PermissionModel": "FineGrained",
     "ParentId": null,
     "ParentKey": null,
     "IsActive": true,
     "FeedType": "Processes",
     "Id": 2879381
   },
   {
     "Key": "ceb2bded-cc40-45f7-9b09-9c100a7d4699",
     "DisplayName": "Support Cases Repro",
     "FullyQualifiedName": "Support Cases Repro",
     "FullyQualifiedNameOrderable": "Support Cases Repro",
     "Description": null,
     "ProvisionType": "Automatic",
     "PermissionModel": "FineGrained",
     "ParentId": null,
     "ParentKey": null,
     "IsActive": true,
     "FeedType": "Processes",
     "Id": 3551671
   }
 ]
}

  1. Add the payload to "Body" and select "Import"

  1. Select "Update connector"

  1. Go to "5. Test" to test the connector
    1. Add a new connection and follow the on-screen steps to log-in

  1. Once authenticated, add the Organization name and Tenant Name to the activity below and click "Test operation"

  1. The response should look like this:

  1. To use the connector, simply create a new Power Automate flow, add a new action, search for the custom Connector and select the action defined.

The custom connector can be defined to have more actions (requests) and those can be further customized. Check Create A Custom Connector From Scratch for more details on Power Automate custom connectors.