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
Posted 4 years ago · Edited 1 year ago·Last reply 4 years ago
3 comments
arthurburkhardt
·4 years ago · EditedIf 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
·4 years ago · EditedIf 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
OP4 years ago · EditedThank you very much worked like a charm.