Luidie
(Luis Saller)
April 10, 2024, 2:32pm
1
Hello,
if there are any Python experts: I need to build a OAuth2 API but I cant make it work. I also cant find any example headers and bodys for the API request anywhere on the internet. If someone could do an example of an script or has done something similar with curl or in a other programming language I would be very thankful.
@Luidie
what framework are you using? flask or something else. Who is your oauth provider? or are you tying to build you own?
This is more suitable for stackoverflow
Luidie
(Luis Saller)
April 10, 2024, 3:00pm
3
Hello, I am building on my own. I got a Python script with the requests library.
If you are building your own provider you can use django.
I would advise against building your own provider if you donât know what you are doing and if its going to be used in a production environment.
https://django-oauth-toolkit.readthedocs.io/en/latest/
and just to clarify you arenât talking about orchestrator api right?
Luidie
(Luis Saller)
April 10, 2024, 6:02pm
5
I want to add queue items to an orchestrator queue and need to authenticate
ok. @Luidie
i have this old format
This is an example code i have removed senstive data for all required paramters look at the swagger definition
import requests
import json
auth_url = "orchurl"
auth_data = {
"tenancyName" : "<your_tenant_name>",
"usernameOrEmailAddress" : "<your_username>",
"password" : "<your_password>"
}
auth_headers = {
'Content-Type': 'application/json'
}
auth_response = requests.post(auth_url, data=json.dumps(auth_data), headers=auth_headers)
access_token = auth_response.json()['result']
queue_url = "url"
queue_data = {
"itemData": {
"Name": "<queue_name>",
"Priority": "Normal",
"SpecificContent": {
"<key>": "<value>"
}
}
}
queue_headers = {
'Authorization': f'Bearer {access_token}',
'Content-Type': 'application/json'
}
queue_response = requests.post(queue_url, data=json.dumps(queue_data), headers=queue_headers)
queue url preceded by
https://cloud.uipath.com/{organizationName}/{tenantName}/orchestrator_/odata/
at the end of your ochestrator url add swagger/index.html for all the api definitions and required paramters
Hi everyone,
I am currently trying to develop an âAct-Botâ using Kore.ai platform and orchestrator.
Therefore I need to push arguments from the Kore.ai platform to an orchestrator queue and process them in UIPath.
Unfortunately I do not have a development background. I have followed the steps described in a Kore.AI Integration documentation and configured a âAuthorizeWithOrchestratorâ request using https://platform.uipath.com/api/Account/Authenticate as in API documentation (https://docs.uipaâŚ
Luidie
(Luis Saller)
April 10, 2024, 6:57pm
7
Thank you very much! I also got the same but the token I get is not working. Now I am trying to use the OAuth2 method.
Luidie
(Luis Saller)
April 10, 2024, 7:27pm
8
I always get the error: âqueuename does not exist!â. I got everything right with folderID and so on. If I use the bearer from swagger it works. So it works with the swagger OAuth2 bearer but with my username/passwort authentication I cant find the queue.
are you using azure active directory.
If your organization uses the Azure Active Directory model, you must register external applications in Orchestrator and use the OAuth flow.
try the below sample snippet see if that works to fetch id and secret you would have to register your script as an external application
import requests
client_id = 'your_client_id'
client_secret = 'your_client_secret'
base_url = 'provder/api'
token_url = f'{base_url}token'
token_data = {
'grant_type': 'client_credentials',
'client_id': client_id,
'client_secret': client_secret,
}
response = requests.post(token_url, data=token_data)
response_json = response.json()
access_token = response_json['access_token']
headers = {'Authorization': f'Bearer {access_token}'}
response = requests.get(f'{base_url}some_endpoint', headers=headers)
print(response.json())
Luidie
(Luis Saller)
January 21, 2026, 7:20pm
10
Thank you! You helped me!
1 Like
HI @Luidie
OAuth2 depends on the grant type, but the most common one is client credentials.
First you request a token:
curl example
curl -X POST https://auth.example.com/oauth/token
-H âContent-Type: application/x-www-form-urlencodedâ
-d âgrant_type=client_credentials&client_id=CLIENT_ID&client_secret=CLIENT_SECRETâ
Youâll get an access token in the response.
Then call the API using that token:
curl -X GET https://api.example.com/data
-H âAuthorization: Bearer ACCESS_TOKENâ
Python example:
import requests
token = requests.post(
âhttps://auth.example.com/oauth/token â,
data={
âgrant_typeâ: âclient_credentialsâ,
âclient_idâ: âCLIENT_IDâ,
âclient_secretâ: âCLIENT_SECRETâ
}
).json()[âaccess_tokenâ]
resp = requests.get(
âhttps://api.example.com/data â,
headers={âAuthorizationâ: f"Bearer {token}"}
)
print(resp.text)
If the API uses another grant type, only the token request body changes.