Controller (SaaS, On Premise)

cancel
Showing results for 
Search instead for 
Did you mean: 

Python Code For Data Extraction using OAuth API Client

SOLVED
Python Code For Data Extraction using OAuth API Client
Vaibhav Vir.Singh
Architect

Re: Python Code For Data Extraction using OAuth API Client

Any thoughts and help in this?
Vaibhav Vir.Singh
Architect

Re: Python Code For Data Extraction using OAuth API Client

Just realized this thread i raised did not have any solution marked.

 

I accomplished so sharing for broader community. 

 

replace 'token' with big token string without quotes in the headers.

 

################

import requests

 

headers = {

    'Authorization': 'Bearer token',

}

 

# Sample Query to fetch all applications

response = requests.get('https://<<CONTROLLERHOST>>:8181/controller/rest/applications', headers=headers, verify=False)

print(response.text) # OR response.content

################

 

Either you use Token directly like above, OR you can get token generated from secret of API Client like below: 

curl -k -X POST -H "Content-Type: application/vnd.appd.cntrl+protobuf;v=1" "https://<<CONTROLLER:8181/controller/api/oauth/access_token " -d “grant_type=client_credentials&client_id=XYZ@customer1&client_secret=4c45*****801”

 

Regards,

VVS