How to Authenticate Jira Rest APIs using Client ID and Client Secret

Phanindra Sagiraju December 1, 2020

Hi, 

I am trying to invoke REST API using Basic Authentication protocol. 

Initially, I used the combination of Email and API Token as suggested by the Cloud REST API documentation

url = "https://<jira-host>.atlassian.net/rest/api/3/issue/<issue-key>"


r = requests.get(url, auth=('username@useremail', 'api_token'),
headers={"Accept": "application/json"})

// Can be also called with HTTPBasicAuth
(auth = HTTPBasicAuth("username@useremail", "api_token"))

Now I would like to replicate this functionality using a Client ID and Client Secret, that I created using Admin API (Attached Image), using the same HTTP Basic Authentication protocol like above instead of OAuth 3LO but when I am using the same code as above, I am getting a 401 error. 

url = "https://<jira-host>.atlassian.net/rest/api/3/issue/<issue-key>"
auth = HTTPBasicAuth("client_id", "client_secret")

headers = {
"Accept": "application/json"
}

response = requests.request(
"GET",
url,
headers=headers,
auth=auth
)

print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))

 

Please let me know where I am going wrong.

 

Thanks in advance, 

Phani

Jira.png

1 answer

0 votes
mogavenasan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 3, 2021

Hi Phani,

From the screenshot that you have provided, you have created an admin API keyAPI keys allow you to manage your organization via the admin APIs.

As for the Basic Auth for Atlassian Cloud platform - we no longer will be able to use this protocol for authentication; Deprecation notice - Basic authentication with passwords and cookie-based authentication

I hope that this helps.

Thanks,
Moga

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events