I'm trying to implement OAuth for an application that I'm building to retrieve data from JIRA via the REST API. I am able to construct and use an authorization url, and get a message indicating that I have successfully authorized my application when I use it. However, when I then try to request the access-token, I always get response code 401, with content 'oauth_problem=token_rejected'.
I am using Python 3, and have pulled apart the code in the 'oauthdance' function within jirashell to see where the breakdown is happening. My application doesn't have a callback url.
oauth = OAuth1(consumer_key,
signature_method=SIGNATURE_RSA, rsa_key=key_cert_data, resource_owner_key=request_token, resource_owner_secret=request_token_secret
)
r = requests.post(
server + '/plugins/servlet/oauth/access-token', verify=verify, auth=oauth)
I've also tried including the 'verifier' received when I authorized the application, but I still got a '401' message.
Update: I've tried this with the Java client as well, and I'm still getting the 401 error. Message is:
WARNING: Authentication error: Unable to respond to any of these challenges: {oauth=WWW-Authenticate: OAuth realm="<redacted>", oauth_problem="token_rejected"}
com.google.api.client.http.HttpResponseException: 401 Unauthorized
oauth_problem=token_rejected
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1070)
at com.google.api.client.auth.oauth.AbstractOAuthGetToken.execute(AbstractOAuthGetToken.java:73)
at com.atlassian.oauth.client.example.JiraOAuthClient.getAccessToken(JiraOAuthClient.java:63)
at com.atlassian.oauth.client.example.OAuthClient.handleGetAccessToken(OAuthClient.java:90)
at com.atlassian.oauth.client.example.OAuthClient.execute(OAuthClient.java:51)
at com.atlassian.oauth.client.example.ClientMain.main(ClientMain.java:18)
I got the answer from https://community.developer.atlassian.com/t/java-oauth-example-does-not-work/3779/2 - turns out the consumer key is case-sensitive. I changed the consumer key to exactly match the value entered in JIRA and everything is working now.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.