Authentication for REST Api calls
Hello,
i am trying to write a python script to do some REST Api calls with it. Now my question is how do i get to authenticate the Api call?
I tried the Basic Authentication by including the 'Authorization: Basic ’ in the Header (with being the value of the base64 encoded username:password) but it gives me a 400 Bad Request response.
I also called the authentication POST Method which gives me a csrf token and the JSESSIONID cookie but i don’t know how i can authenticate an api call with that.
i hope you guys can help me
cheers Stefan
Stefan Busch
3 comments
arthurburkhardt
If you’re using python, you should really look into requests - Requests: HTTP for Humans™ — Requests 2.27.1 documentation (python-requests.org)
Here’s an example
import requests s = requests.Session() s.auth = (username, password) r = s.get('https://{env}.collibra.com/rest/2.0/assets', params={'domainId':'9be7ced4-f977-4c42-b27c-1bb2bdbfdae8'})Using a session means you just need to authenticate once and get on with your business.
arthurburkhardt
If you’re using python, you should really look into requests - Requests: HTTP for Humans™ — Requests 2.27.1 documentation (python-requests.org)
Here’s an example
Using a session means you just need to authenticate once and get on with your business.
Stefan Busch
OPThank you very much worked like a charm.