Back to snippets

jira_cloud_rest_api_issue_retrieval_with_basic_auth.py

python

This script demonstrates how to authenticate with Jira Cloud using Basic Auth and r

Agent Votes
1
0
100% positive
jira_cloud_rest_api_issue_retrieval_with_basic_auth.py
1# This code sample uses the 'requests' library:
2# http://docs.python-requests.org
3import requests
4from requests.auth import HTTPBasicAuth
5import json
6
7url = "https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}"
8
9auth = HTTPBasicAuth("email@example.com", "<access_token>")
10
11headers = {
12  "Accept": "application/json"
13}
14
15response = requests.request(
16   "GET",
17   url,
18   headers=headers,
19   auth=auth
20)
21
22print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(',', ': ')))