0

我试图通过访问远程 API 来获得 REST 响应,我正在从本地机器获得一些其他服务器的响应,但仅从一个特定的 IP 地址我得到响应 X-Mashery-Error-Code ,值:ERR_403_NOT_AUTHORIZED。

我与服务提供商核实了他们没有阻止任何 IP 地址。我正在传递一个 Api 密钥和一个使用 sha256 使用共享密钥生成的签名,如下所示。org.apache.commons.codec.digest.DigestUtils.sha256Hex(apiKey + sharedSecret + System.currentTimeMillis() / 1000);

这可能是什么原因不能从特定的 IP 地址工作。

任何帮助将不胜感激。

4

1 回答 1

0

ERR_403_NOT_AUTHORIZED happens with Mashery when your authentication is not proper. I can mean that your key/secret is not correct, or your oAuth2 token is expired, or your SHA256/MD5 signatures are not proper.

Mashery-Error-Code ,Value : ERR_403_NOT_AUTHORIZED normally doesn't happen when an IP is blocked.

In this case, I think the issue is beacuse you use System.currentTimeMillis() / 1000.

Instead of that, can you try Math.round(new java.util.Date().getTime() / 1000)

org.apache.commons.codec.digest.DigestUtils.sha256Hex("apiKey" + "sharedSecret" + Math.round(new java.util.Date().getTime() / 1000))

If this didn't work, can you check if there is another header X-Error-Detail-Header, if yes what is it value ?

于 2017-07-26T14:37:40.697 回答