我正在关注this设置 Oauth。
我已经设置了公钥,下载了 jar :
rest-oauth-client-1.0.one-jar.jar
rest-oauth-client-1.0-sources.jar
页面上提到, 但是当尝试执行时:
java -jar rest-oauth-client-1.0.one-jar.jar requestToken https://mycompanyname.atlassian.net
我收到一个奇怪的错误..我已经设置了消费者 key 。 错误是:
Jul 01, 2015 3:38:26 PM org.apache.http.impl.client.DefaultRequestDirector handleResponse
WARNING: Authentication error: Unable to respond to any of these challenges: {oauth=WWW-Authenticate: OAuth realm="https%3A%2F%2Fmycompanyname.atlassian.net", oauth_problem="consumer_key_unknown"}
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: consumer_key_unknown
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)
... 7 more
有人可以帮我解决这个错误吗? 请不要建议我this关联。我已经看过这个文档好几次了。 我一直在尝试使用 python 进行相同的操作,但我不知道如何获取消费者 secret 。
最佳答案
如果您尝试使用 jar Rest-oauth-client-1.0.one-jar.jar 获取 token ,您的消费者 key 必须是“硬编码消费者”。
谢谢!
关于java - Oauth 进程中从 JIRA 获取请求 token 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31159701/