Authorization on REST API of TestManager

Hi,

It try to simply get the list of projects of Test Manager Texte préformatéfrom the rest api . When on browser already connected to UiPath, it works using the swagger (but the curl command showing it works with the XSRF token).
From Postman, curl on command line or java programming, no way : I tried with a personal access token or an OAuth2 token, sent in header on Bearer, but I always get a 401 Unauthorized response.

Can you please tell me how to do that ?
(Request being /api/v2/projects)

Thanks for help,

AB

Hi Arnaud,
have you found a solution to this problem? I am facing the same problem. In swagger UI I can use the bearer token without any problems. But in UiPath Studio using the “HTTP Request”-Activity I am facing the 401 problem. The bearer token was extracted from the Orchestrator Authenticate API.

Or is there an authentication method in the Test Manager API?

Hi @WalterB

Yes, you would need to get access token from using test manager api scope to be able to get success from any test manager api calls.

Kindly update/create your app registration to use test manager scope as well.

Hi Sonali,

Thank you for your response.

Well, I created the App ID & Secret successfully and assigned the necessary rights in the scope. But how do I send it to the API?

Should I use the app id & secret as body in all my requests or does the Test Manager API have an own “Authenticate” API?

There are some fields to enter the information, but I put the credentials into the body. Like this:

varBody: “{”“client_id”“: ““APPID””,”“client_secret”“:”“APPSECRET”“}”

Hi @WalterB

Authenticate api remains same for Apis of all different resources.

Please refer below UiPath article on same.

https://uipath.my.salesforce-sites.com/CaseView/articles/en_US/Knowledge/How-To-Make-Orchestrator-API-Requests-Using-HTTP-Request-Activities-or-Orchestrator-HTTP-Request

Once done, fetch the access token. Please note that scope to be provided with certain TM. Permissions to be able to later use this token for test manager endpoints.

And then hit the required endpoint urls of test manager resource.

Hi Sonali,

The ROPC authentication works fine to retrieve the bearer token. I can use it in swagger UI to send messages to the Test Manager API.

But the main problem is sending messages to the Test Manager API when I use UiPath Studio activities like “HTTP Request”. In this case I get a HTTP 401 error. (Even when I use the import method of the HTTP Request Activity I get an 401). The error description is “error_description=“The audience ‘IdentityServerApi, OrchestratorApiUserAccess’ is invalid””

Do you have a knowledge article about OAUTH authentication like in Orchestrator - External Applications (OAuth) ?

@WalterB

You get this error because the scope you have defined in the external application does not have required permissions.

When you setup an external application, you will need to provide scopes like the one I shared in screenshot above. To create an external application , go to automation cloud->admin-> external applications-> register a new application, add the scopes save it.

More here

Then first try in postman to use the client id, secret and scope from your external application to get an access token.

Post which you can use that token to hit different endpoints.

Once you get it working using postman, you can simply use http request to get access token and then 2nd http request to hit the TM endpoint you want.

Hope this helps.

Hi Sonali,

Thank you for your help. I have solved the issue. My last problem was the format of my body. It was still in json instead of the format in my content-type.

Info for everyone:

To get an access_token by using the Client ID & Secret from External Application Account use HTTP Request as in the following instructions:

Orchestrator version: 24.10. Standalone

API: baseURL of the Orchestrator + “identity/connect/token”
Header:

  • accept: application/json
  • content-type: application/x-www-form-urlencoded

Body: “client_id=APPID&client_secret=APPSECRET&grant_type=client_credentials&scope=TM.Default
Replace ‘TM.Default’ with a scope you need, multiple scopes are possible.

Then you’ll receive a bearer token. Deserialize the json from the response content as jsonResponseContent and parse it by using "Bearer " + Convert.ToString(jsonResponseContent.GetValue(“access_token”)) on the response content.

Use the Bearer token as header info in “Authorization” in subsequent HTTP Requests.

Note: The external application account can only be used in its scope.

Kind regards,

WalterB