Hi everyone,
I wanted to update this thread as some things have changed. While you can still use Basic Auth for Jira Cloud REST API, the use of passwords and cookie based auth no longer works. More details in Deprecation notice - Basic authentication with passwords and cookie-based authentication.
Please check out our guide in Basic auth for REST APIs. It explains in detail that after you have created your Cloud API token, that you then need to build a string in the format of user@example.com:API_TOKEN and then base64 encode that string. You can then pass that encoded string as part of an authorization header for your REST API requests.
Once you have that setup, I'd recommend checking out the Jira Cloud REST API Reference for the endpoint you want to call. The Cloud version of this document has examples in various language syntax such as python, Java, PHP, Node.js, and cURL.
# This code sample uses the 'requests' library:
# http://docs.python-requests.org
import requests
from requests.auth
import json
url = "/rest/api/3/myself"
headers = {
"Authorization": "Basic [encodedstring]",
"Accept": "application/json"
}
response = requests.request( "GET", url, headers=headers )
print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))
This should work to make basic auth requests in Jira Cloud from Python.
I hope this helps.
Andy
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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In this article I go over generating a Jira Python client from the Open API spec. The code it generates includes the correct requirements.txt to pull in the required libraries.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
It is basic authentication, but instead of the password you pass API token:
https://confluence.atlassian.com/cloud/api-tokens-938839638.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi alexey,
i have already tried this code with token but getting status 200 and html format code is appearing..
import requests
url="https://xxxxxxx.atlassian.net"
body={
"username":"xxxxxxxxx@xxxx.com",
"password":"token"
}
headers = {"content_type":"application/json"}
r=requests.post(url,data=body,headers=headers)
print(r.text)
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.