Unable to retrieve the correct authentication cookie using UiPath Studio for API automation

I have been trying to retrieve authentication cookies that can be used for API calls. I attempted to use the Get Browser Data activity, but it is not returning the required cookies.

Hi @Akshay2

This is normal behavior.

Get Browser Data cannot retrieve authentication cookies (HttpOnly / secure cookies). They are blocked for security.

Use the API’s authentication method instead (token, OAuth, API key) and call the API directly.

Hi @Akshay2 ,

As @Monali_Vekariya said, we cannot retrieve the auth related data, but if you want to extract the rest, you can follow these steps

There are 2 ways,

  1. Output the data to a text file and get the cookie
    Getting cookies from current browser - #5 by mrizwan

  2. Loop through the JSON object

https://forum.uipath.com/t/how-to-find-a-specific-cookie-from-get-browser-data-activity/525526/6

Happy automation :robot:

@Akshay2

This will be wrong approach you are trying.

Correct approach is using proper authentication. Follow this documentation

Hi @Akshay2

To retrieve auth token for API requests, please follow below approach:

  1. Register external app from automation cloud and retrieve client id and secret.
  • Please note that while registering, provide application scopes based on what api you are looking to hit. There are various APIs you can access(few examples being are orchestrator api, platform management api , test manager api).
  • Let’s say you want to utilize orchestrator API, then it is very important to select the proper application scopes in there, otherwise you will keep getting invalid scope error.
  • Any of the scopes you choose to use, please note that you can only select 2 types together… fore.g. if you are selecting scope for administration.. then you can either select (or.administration and or.administration.read) or (or.administration and or.administration.write). Selecting all 3 results in error. Same applies to any scope you select from the list.
  1. Once you have registered, Get Access Token using endpoint(GET):
    https://cloud.uipath.com/{{your org name}}/identity_/connect/token

  2. if you are using postman to try first and get token, then your endpoint and body would like below..

  1. In response of this request, you will get access token.

  2. Now you are ready to utilize specific API endpoints(get/post).

Hope this helps.

Regards

Sonali

@Akshay2

Welcome to the community

Can you try to write the output of get browser data to a text file and check if the required cookies are present…if you log most of the times the data would be truncated and it might look like the required cookies are missing

Cheers