Java HttpResponseProxy HTTP/1.0 401未经授权

Java HttpResponseProxy HTTP/1.0 401未经授权,java,web-services,rest,authorization,Java,Web Services,Rest,Authorization,我有一个GET请求,它在Postman上运行良好,但在Eclipse上不起作用。每次我得到这样的回答: HttpResponseProxy{HTTP/1.0 401 Unauthorized [Cache-Control: no-cache, Pragma: no-cache, Content-Type: application/json; charset=utf-8, Expires: -1, Server: , WWW-Authenticate: Raven, Date: Fri, 18 M

我有一个GET请求,它在Postman上运行良好,但在Eclipse上不起作用。每次我得到这样的回答:

HttpResponseProxy{HTTP/1.0 401 Unauthorized [Cache-Control: no-cache, Pragma: no-cache, Content-Type: application/json; charset=utf-8, Expires: -1, Server: , WWW-Authenticate: Raven, Date: Fri, 18 Mar 2016 09:47:13 GMT, Content-Length: 32, X-Cache: MISS from proxy, X-Cache-Lookup: MISS from proxy:3191, X-Cache: MISS from site.domain.com, X-Cache-Lookup: MISS from site.domain.com:8668, Via: 1.0 proxy:3191 (squid/2.6.STABLE21), 1.0 site.domain.com (squid/3.1.10), Connection: keep-alive]}
这是我打电话的方式:

    //String request; String key;

    String signature = generateSignature(request, "HmacSHA256");

    Resource resource = restClient.newBuilder()
            .type(TypeFactory.defaultInstance()
            .constructCollectionType(List.class, MyObject.class))
            .timeout(30000)
            .header("Authorization", "Raven " + signature)
            .header("X-Raven-ApiKey", key)
            .header("Content-Type", "application/json")
            .param("SinceDate", sinceDate)
            .param("Timestamp", String.valueOf(timestamp))
            .build();
    return resource.get();
出现此错误的可能原因是什么


谢谢

@cdelmas你是正确的。我使用Base64对签名进行编码,它在最后添加了“\r\n”字符。我移除了它们,它就工作了。

@cdelmas你是正确的。我使用Base64对签名进行编码,它在最后添加了“\r\n”字符。我删除了它们,它就工作了。

也许签名编码不好。401表示授权过程失败,可能是因为Raven签名无效(或者可能是因为Raven API密钥)。可能是因为签名编码不正确。401表示授权过程失败,可能是因为Raven签名无效(或者可能是因为Raven API密钥)。