Api 香港空气污染指数

Api 香港空气污染指数,api,curl,hmac,kong,Api,Curl,Hmac,Kong,请 我需要一些关于配置和使用HMAC for KONG API的帮助 我是按照手册发布的演示凭证鲍勃/secret456 问题在于HMAC auth的使用。我仍然得到403错误-禁止 以下是我的命令行输出: root@test.com# curl -v http://X:8000/public4/ -H 'Authorization: hmac username="bob", algorithm="hmac-sha1", headers="Date content-md5", signature

我需要一些关于配置和使用HMAC for KONG API的帮助

我是按照手册发布的演示凭证鲍勃/secret456

问题在于HMAC auth的使用。我仍然得到403错误-禁止

以下是我的命令行输出:

root@test.com# curl -v http://X:8000/public4/ -H 'Authorization: hmac username="bob", algorithm="hmac-sha1", headers="Date content-md5", signature="Base64(HMAC-SHA1(secret456))"'
> GET /public4/ HTTP/1.1
> User-Agent: curl/7.35.0
> Host: XXX:8000
> Accept: */*
> Authorization: hmac username="bob", algorithm="hmac-sha1", headers="X-Date content-md5", signature="Base64(HMAC-SHA1(secret456))" <<- IS THIS CORRECT?
>
< HTTP/1.1 403 Forbidden
< Date: Mon, 27 Mar 2017 13:15:07 GMT
< Content-Type: application/json; charset=utf-8
< Transfer-Encoding: chunked
< Connection: keep-alive
* Server kong/0.9.7 is not blacklisted
< Server: kong/0.9.7
<
{"message":"HMAC signature cannot be verified, a valid date or x-date header is required for HMAC Authentication"}
* Connection #0 to host XXX left intact
如有任何提示或指导,将不胜感激。Github问题已解决,评论没有帮助。我还是犯了同样的错误


非常感谢。

您在授权头中包含了字符串文字“Base64(HMAC-SHA1(secret456))”。您应该计算密码的HMAC,对其进行base64编码,并包含该值。

“base64(HMAC-SHA1(secret456))”:您需要计算HMAC并对其进行base64编码
{
  "total": 1,
  "data": [
    {
      "consumer_id": "e98e1ca2-2f13-4430-a658-cabdd4e6cd26",
      "created_at": 1490616124000,
      "username": "bob",
      "id": "037db653-8b38-4a7e-b139-1040856b7cfb",
      "secret": "secret456"
    }
  ]
}