【问题标题】:Connect jersey client to JIRA REST api with oAuth使用 oAuth 将 jersey 客户端连接到 JIRA REST api
【发布时间】:2016-10-18 17:32:54
【问题描述】:

我想使用 jersey 客户端对 JIRA 进行 REST 调用。我想通过oAuth。有没有人有示例代码。我尝试了以下文档,但这对我来说非常混乱。

ConsumerCredentials consumerCredentials = new ConsumerCredentials("hardcoded-consumer", "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxZDzGUGk6rElyPm0iOua0lWg84nOlhQN1gmTFTIu5WFyQFHZF6OA4HX7xATttQZ6N21yKMakuNdRvEudyN/coUqe89r3Ae+rkEIn4tCxGpJWX205xVF3Cgsn8ICj6dLUFQPiWXouoZ7HG0sPKhCLXXOvUXmekivtyx4bxVFD9Zy4SQ7IHTx0V0pZYGc6r1gF0LqRmGVQDaQSbivigH4mlVwoAO9Tfccf+V00hYuSvntU+B1ZygMw2rAFLezJmnftTxPuehqWu9xS5NVsPsWgBL7LOi3oY8lhzOYjbMKDWM6zUtpOmWJA52cVJW6zwxCxE28/592IARxlJcq14tjwYwIDAQAB");
AccessToken accessToken = new AccessToken("Token", "Secrete");
        Feature feature = OAuth1ClientSupport.builder(consumerCredentials)
                .feature()
                .accessToken(accessToken)
                .build();


        Client client = ClientBuilder.newBuilder()
                .register(feature)
                .build();

        Response resp =
                client.target("http://jira.company.com/rest/api/2/project")
                    .request()
                    .get();

        System.out.println(resp.readEntity(String.class));

这就是我现在所拥有的。我得到oauth_problem=signature_method_rejected 作为错误

【问题讨论】:

    标签: rest oauth jersey jira


    【解决方案1】:

    您可以使用文档中引用的Twitter example。你也在使用OAuth1AuthorizationFlow吗?基于documentation,这是你应该使用的东西,twitter示例也使用它。

    您需要坚持使用普通的泽西岛吗?有一个名为 jira-rest-java-client 的库,您可以使用它:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-08
      • 2023-03-28
      • 1970-01-01
      • 2020-06-11
      • 1970-01-01
      • 2016-02-27
      相关资源
      最近更新 更多