Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×I have a Google App Engine Python application that interacts with a JIRA Cloud instance.
To date the application makes urlfetch
calls to JIRA using Basic Authentication but as it is now making dozens of separate REST calls both POST and GET I was hoping that using cookie authentication would reduce the latency somewhat.
example Basic-Authentication code that works:
result = urlfetch.fetch(jira_url, deadline=60, headers={"Authorization": "Basic %s" % base64.b64encode("%s:%s" % (username, password)) })
and cookie alternative:
result = urlfetch.fetch(jira_url, deadline=60, headers={"X-Atlassian-Token": "no-check", "Cookie": "JSESSIONID=529…snip…C4C" })
I retrieved the JSESSIONID successfully using the instructions but the cookie query will only return "401 - Unauthorized" error while loading this page.
errors as if the cookie has expired.
{ "errorMessages" : [ "You do not have the permission to see the specified issue.", "Login Required" ], "errors" : {} }
In case it is relevant, I am recalling the cookie from Memcache as most of the interactions are made from a Task Queue and necessarily a separate thread, but the cookie is generated immediately before the recall.
Hi Jeff,
The node.js example you linked to actually fails due to the same issue when using the cloud instance. Authentication works but the embedded query in the example the attempts to run with the cookie fails with a 401. Would be good to have someone at Atlassian either confirm the issue or provide some guidance.
Looking at the actual responses coming from the Atlassian on demand servers the cookie expiration is january 1st 1970. Not sure if thats the root cause but would make sense the next request would return a 401.
Your request looks pretty much correct based on the documentation - https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-cookie-based-authentication.
The only thing that maybe I would recommend is setting your content-type to application/json in your headers as well, as per the urlfetch documentation if you do not specify, then it will default to www-urlform-encoded, which is likely to cause problems? From https://cloud.google.com/appengine/docs/python/outbound-requests:
When sending an HTTP
POST
request, if aContent-Type
header is not set explicitly, the header is set tox-www-form-urlencoded
. This is the content type used by web forms.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.