Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jira OAuth - Unable to create application link

I am trying to create an application which uses jira for authentication. I am using Jira Rest api for the same. In the documentation it says to use the same public key and consumer-key to create application link as given in the doc. This works fine, and I am able to create access-token. But in java code as mentioned in this, I am not sure what should be given for private_key. I tried two methods-

  1. Generated a random private key using rsa and provided it in place of private_key which didn't work. It gave exception telling length too long. I tried for 2048, 1024, 512, 256 and 128 bits. Everything gave same error.

Application link:

Consumer-key: hardcoded-consumer

Consumer Name: hardcoded-consumer

Public Key: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxZDzGUGk6rElyPm0iOua0lWg84nOlhQN1gmTFTIu5WFyQFHZF6OA4HX7xATttQZ6N21yKMakuNdRvEudyN/coUqe89r3Ae+rkEIn4tCxGpJWX205xVF3Cgsn8ICj6dLUFQPiWXouoZ7HG0sPKhCLXXOvUXmekivtyx4bxVFD9Zy4SQ7IHTx0V0pZYGc6r1gF0LqRmGVQDaQSbivigH4mlVwoAO9Tfccf+V00hYuSvntU+B1ZygMw2rAFLezJmnftTxPuehqWu9xS5NVsPsWgBL7LOi3oY8lhzOYjbMKDWM6zUtpOmWJA52cVJW6zwxCxE28/592IARxlJcq14tjwYwIDAQAB

  1. Generated private and public key pair and provided the same in application link and in code respectively. But in this case, I am unable to create access token. It is giving -

Application link:

Consumer-key: hardcoded-consumer

Consumer Name: hardcoded-consumer

Public Key: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC0YjCwIfYoprq/FQO6lb3asXrx LlJFuCvtinTF5p0GxvQGu5O3gYytUvtC2JlYzypSRjVxwxrsuRcP3e641SdASwfr mzyvIgP08N4S0IFzEURkV1wp/IpH7kH41EtbmUmrXSwfNZsnQRE5SYSOhh+LcK2w yQkdgcMv11l4KoBkcwIDAQAB

Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.simontuffs.onejar.Boot.run(Boot.java:340)
    at com.simontuffs.onejar.Boot.main(Boot.java:166)
Caused by: java.lang.RuntimeException: Failed to obtain request token
    at com.atlassian.oauth.client.example.AtlassianOAuthClient.getRequestToken(AtlassianOAuthClient.java:66)
    at com.atlassian.oauth.client.example.JIRAOAuthClient.main(JIRAOAuthClient.java:52)
    ... 6 more
Caused by: net.oauth.OAuthProblemException: signature_invalid
    at net.oauth.client.OAuthResponseMessage.toOAuthProblemException(OAuthResponseMessage.java:83)
    at net.oauth.client.OAuthClient.invoke(OAuthClient.java:306)
    at net.oauth.client.OAuthClient.invoke(OAuthClient.java:260)
    at net.oauth.client.OAuthClient.getRequestTokenResponse(OAuthClient.java:190)
    at com.atlassian.oauth.client.example.AtlassianOAuthClient.getRequestToken(AtlassianOAuthClient.java:57)

Can someone explain me what should be done? Am I missing something here? And also what is the difference between shared key, consumer key and public key?

Thanks in advance

like image 602
DivyaMenon Avatar asked Feb 01 '16 07:02

DivyaMenon


People also ask

How do I enable issue link in Jira?

Navigate to the Jira Software admin panel using the icon in the upper right and select Issues. In the left hand sidebar, select Issue linking under Issue features. Make sure that Issue linking is set to ON. If it's not, select Activate to enable it.

What is OAuth impersonation?

OAuth with impersonation Impersonating authentication makes requests on behalf of the user who is currently logged in. Note that Atlassian OAuth with impersonation can only be used for application links between Atlassian applications.


1 Answers

The exception occurs due to ending with "/" in JIRA base URL (caused by net.oauth.OAuthProblemException: signature_invalid).

The correct request is:

java -jar rest-oauth-client-1.0.one-jar.jar requestToken https://jira_base_server_url http://your_redirctedUrl
like image 99
bhuvaneswari kalimuthu Avatar answered Sep 24 '22 02:09

bhuvaneswari kalimuthu