VaclavDedik VaclavDedik - 1 month ago 37
Python Question

JIRA REST API and kerberos authentication

I am struggling with Jira REST API authentication via kerberos. Basic authentication works as expected.

If I access the login page with the web browser (after I did kinit) and then use the generated JSESSIONID in my python script, I can use REST without getting 401. But I have no ide how to do that with my python script, I tried to use requests_kerberos, but when I request the login page, it simply returns the basic login form instead of automatic login.

Do you know how to use JIRA REST API with kerberos authentication?

Thanks for you answers.

Answer

After a day of struggle I finally figured it out.

First you have to send an HTTP GET request to ${jira-url}/step-auth-gss:

r = requests.get("https://example-jira.com/step-auth-gss", auth=requests_kerberos.HTTPKerberosAuth())

Then you get the JSESSIONID from the cookie header and you can REST away:

rd = requests.get(url, headers={"Cookie": "JSESSIONID=%s" % r.cookies['JSESSIONID']})