Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

JIRA REST API cookie based authentication fails when used with python requests

I've been trying to get issue data from the REST API v2 by using cookie based authentication and the python requests library, the /auth/1/session requests returns a 200, cookies are set but all following requests on the same requests.Session object return a 401:

> from requests import Session
> s = Session()
> res ="https://jira.url/jira/rest/auth/1/session",
... json={"username":"user","password":"pass"})
> res.status_code
> s.cookies
<RequestsCookieJar[<Cookie JSESSIONID=... for jira.url/jira>, <Cookie atlassian.xsrf.token=... for jira.url/jira>]>
> res = s.get("https://jira.url/jira/rest/api/2/issue/ISSUE-100")
> res.status_code
> r.request.headers
{'User-Agent': 'python-requests/2.18.4', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Cookie': 'JSESSIONID=...; atlassian.xsrf.token=...'}

(In case it's not clear: I removed cookie contents, urls and credentials in the example above)

Furthermore, I get the following message in the response:

os_authType was 'any' and an invalid cookie was sent.

 It seems a bit strange; I'm using the same session, which keeps the connection alive by default, and still, the session cookie gets invalidated. 

Is this a problem by JIRA or does requests just not actually keep the Session open?


1 answer

0 votes


Can you try to trace the requests?


I had the same problem here


After keeping as object it works well. 

Suggest an answer

Log in or Sign up to answer

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you