【发布时间】:2016-06-12 10:00:26
【问题描述】:
我正在尝试为使用 REST API 的 JIRA 构建一个插件。使用 Jersey 客户端连接 Web 资源并获取 JSON 响应,即ClientResponse。在这里,我在标题中使用Authorization,并在需要用户名和密码的地方使用了基本类型授权。我想使用会话或任何其他类型的授权技术,因为没有人以纯文本形式提供密码,然后对用户名和密码进行加密并发送请求。所以我的问题是:有没有其他方法可以在 JIRA 中调用 REST API,这样我就可以在不使用密码的情况下调用其他 REST API。
我的代码是:
Client client = Client.create();
String resturl="https://domainname.com/rest/gadget/1.0/currentUser";
WebResource webResource = client.resource(resturl);
ClientResponse response = webResource.header("Authorization", "Basic" + auth).type("application/json").get(ClientResponse.class);
int statusCode = response.getStatus();
String jsonResponse = response.getEntity(String.class);
w.write("Status:"+statusCode);
w.write("Response:"+jsonResponse);
我收到了上述代码的响应,但没有人提供纯文本密码来访问资源。有人知道这个问题吗?
【问题讨论】:
标签: oauth jira-plugin jersey-client jira-rest-api