Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to use OAuth 1.0a for REST APIs in Python

Lishen Liu August 26, 2023

I have created an access token according to this article OAuth 1.0a for REST APIs (Legacy) (atlassian.com)

 

After playing around with the access token on Postman, I can indeed get it working using the RSA-SHA1 Signature Method. I can successfully make a GET and POST request.

 

But I don't really how to achieve this same on Python code. Then I noticed this discussion post. REST Api Oauth python : oauth_problem=signature_me... (atlassian.com)

 

I followed the exact thing, but I got an error stating that it was missing a parameter.

TypeError: load_pem_private_key() missing 1 required positional argument: 'backend'

 

I don't really how to get Jira REST API working in Python now. Please help me out!

1 answer

0 votes
Rick Westbrock
Contributor
August 28, 2023

I'm using the v3 APIs and the way I have configured authorization in Postman is to use Basic Auth with the username but in the Password field I use the API token. This might not truly be OAuth in the way you expect but at least is uses an API token instead of password and it's the closest thing to using true OAuth for user-initiated activity outside of Forge and Connect apps that I could find.

The v3 API docs have a section for Ad-hoc API calls which has a link to Basic auth for REST APIs. The latter is where it describes using Basic Auth with the API token.

Basic auth for REST APIs 

I actually had to raise a support case about this same thing for the Confluence APIs and the support agent told me "After you have created the API key for Confluence Cloud, you can replace the password you're using with the API key in basic auth, more details available in ([2] - Use an API token panel)." I pasted that text below for reference and I found the same holds true for Jira:

"A primary use case for API tokens is to allow scripts to access REST APIs for Atlassian cloud products using HTTP basic authentication.

Depending on the details of the HTTP library you use, simply replace your password with the token."

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events