Enable CORS policy for Cloud Orchestrator

I just tried the same in the angular application, it is returning me the data.Can you check in the response tab beside the preview tab and check what is the response you are getting? @deepak.naidu

Hi Hareesh,
The response tab also has the same response i.e. OK. I’m confused as to why this sort of behavior is happening. :thinking::thinking:

Regards,
Deepak N

Just leave the network :slight_smile: and try running the code and use console.log to display the response. I hope you are doing it already.

I mean, don’t go to the network tab. Check the response clicking on the button you have and as you have console.log, check the response in console @deepak.naidu

Hi Hareesh,

I tried a static and manual approach where I defined the access_token in my header for POST Jobs - Start Jobs with Inputs and to my surprise, this works. I got the access_token from POSTMAN and defined it statically inside my header request.

It seems that I’m getting issues when I’m generating the access_token from another API i.e. the following

where the endpoint is https://account.uipath.com/oauth/token. If you notice, this is different from the following

where the endpoint is https://platform.uipath.com/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs

Hope this provides you some more clarity on the issue.

Regards,
Deepak N

Yes, I think we can use both , but in the API documentation, this is the URL we have to authenticate

https://platform.uipath.com/api/account/authenticate

… Can you try this URL for all api calls and check @deepak.naidu

That is correct, but according to the following thread Consuming APIs with the new Cloud Orchestrator, basic authentication is no longer supported with the new Cloud Orchestrator as it gives Invalid Credentials error even when we have defined the correct credentials.

Moreover, to get the around this in the new Cloud Orchestrator, I have followed the steps as mentioned in Consuming Cloud API thread. Using these steps only, I was able to get stats, robots, start jobs, etc.

1 Like

I mean we need to get the Authorization token and the logical name now to authenticate using that link… will send you the steps soon…

Out of office :slight_smile:

That would be highly appreciated.
Thanks Hareesh. :innocent:

@deepak.naidu

Check this post, I have given the clear points

And here is the documentation if you want clear idea about API

https://orchestrator.uipath.com/v2019/reference#consuming-cloud-api

And let me know if you are running this javascript code in the browser to get the code challenge and code verifier

https://repl.it/languages/nodejs

1 Like

Hi Harresh,

Yes, I’m doing all the pre-liminary tasks manually in the browser and POSTMAN, i.e. to get code challenge(repl.it), code verifier(repl.it), acquiring authorization code(browser), account logical name(POSTMAN), getAccountsForUser(POSTMAN), service instance logical name(POSTMAN), and refresh token(POSTMAN).

The next step i.e. getting the access_token is implemented using the POST request in my React Application, where I’m passing the refresh token acquired from the previous manual steps.
This is exactly where I’m facing the problem, as I’m passing the correct POST request, it is just returning OK as response, whereas it should return the access_token and the id_token.

That’s strange @deepak.naidu,

Still confused … If you get the response in postman, you have to get the response in application as well. Please check the request once again and try :slight_smile:

And what’s more confusing is that I’m only facing issues with acquiring access_token as the endpoint is different i.e. account.uipath.com, whereas to start jobs, get stats, or any other requests, it works fine if I define the access_token manually in my application, as in this case, the endpoint is platform.uipath.com. :thinking::thinking: Nonetheless, let me try again :smiley:

I have only one query, are you able to get the correct response for this request?

I think you mentioned that you were successful in integrating it in your angular application. Please let me know.

Regards,
Deepak N

@HareeshMR Could you please advise on this? Were you able to successfully get this running in your application? I even tried changing the Refer URL from localhost to an HTTPS URL. But still not getting the access_token just the OK response. From what I assume, it’s not accepting the headers in the request, so it is not processing the JSON body that I’m sending in the POST request.

Any help would be highly appreciated, this is the only place that I’m stuck at to complete the POC. :slight_smile:

Regards,
Deepak N

Bro … Hold on… we are doing a blender mistake. I did it right in my code but you are missing this steps :wink:

We have to change the code verifier in this URL and then we need to login with the Orchestrator credentials . It will give the status as OK and the new URL with the code which we need to pass in the authentication request to get the access token

Using that code in the request body will give us the access token

1 Like

Are you able to get the expected now @deepak.naidu ?

Hi Hareesh,

I think I got the resolution, not the perfect but should work.

I’m trying a way to use cURL request using Node request module, but I’m not familiar with NodeJS. :sweat_smile::sweat_smile::laughing::laughing:

Hope this provides you clarity.

If we can get UiPath to allow access to get access_token from other places except POSTMAN then it would be amazing. Coz, with POSTMAN, I’m getting all correct responses. It’s just with my React application, it is giving CORS issue for access_token API request.

Regards,
Deepak N

It would be difficult in the UiPath to capture the URL , but we can do that in React application @deepak.naidu. CURL is also an alternative as we don’t need to bother about http or https or anything. We don’t need to bother about the protocal.

What is the body you are sending to get the access-token in postman?

I spoke to a developer who is somewhat of an expert in APIs, he thinks that when I’m sending using my React application, the User Agent is not getting passed. But, if I’m using cURL then it would consider it as a normal request and therefore would give the correct response as well.

Strange that I’m passing the same thing as it is mentioned in the documentation.
Nonetheless I finally have a solution to my issue.

Thank you Bro for helping out, really did a great help in solving the issue.

Note: I don’t know which response to mark as the solution. :sweat_smile::laughing:

Regards,
Deepak Naidu

Can you give me some more idea on the cURL @deepak.naidu

Oh, Its strange :thinking:

Mark yourself or any other which you found as useful :wink: