REST Api Oauth python : oauth_problem=signature_method_rejected Edited

I've used basic authentication with the REST API with great success, so seems sensible to move to OAuth.

I've followed the Java based example here and it worked well enough, giving me the access token and secret, as well as retrieving data. Yay!

But all our systems are in Python - should be easy huh? 

1/ The Atlassian python examples don't work - not with our Python2.7 libraries, as RSA SHA1 appears deprecated due to vulns. At the point of hashing the data, python throws raise NotImplementedError("Use module Crypto.Cipher.PKCS1_OAEP instead")

The Atlassian example is clunky anyway - we use the requests library for the existing access, so I have used the requests_oauthlib OAuth1.

token_auth = OAuth1(consumer_key, consumer_secret, auth_token,auth_token_secret)

response = requests.get(data_url,auth=token_auth)

but this fails with

response: 400
Response: oauth_problem=signature_method_rejected


1 answer

I know it's bad form to answer your own question - but I've got the answer after quite a bit of fruitless  searching - so here it is:

Assuming you have the access token and secret, you just need to create your OAuth1 authentication object with the right parameters:

import requests
from requests_oauthlib import OAuth1
from oauthlib.oauth1 import SIGNATURE_HMAC, SIGNATURE_RSA

key = open("<yourprivatekey.pem>").read()
token_auth = OAuth1(consumer_key, consumer_secret, auth_token,token_secret,

response = requests.get(data_url,auth=token_auth)

This makes me super happy as I have a beautiful API class for jira and confluence, and I only have to change the "auth=" part of the call to requests to move to the super-quick oauth authentication.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Monday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

727 views 6 13
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you