我正在学习 Apigility(Apigility 文档 -> REST 服务教程)并尝试通过 cURL 发送带有基本身份验证的 POST 请求:
$ curl -X POST -i -H "Content-Type: application/hal+json" -H "Authorization: Basic YXBpdXNlcjphcGlwd2Q=" http://apigilityhw.sandbox.loc/status
YXBpdXNlcjphcGlwd2Q=
是带有我的凭据的 base 64 编码字符串apiuser:apipwd
。凭据保存在/data/htpasswd
( apiuser:$apr1$3J4cyqEw$WKga3rQMkxvnevMuBaekg/
) 中。
看起来像这样:
HTTP/1.1 401 Unauthorized
Server: nginx/1.4.7
Date: Mon, 22 Sep 2014 07:48:47 GMT
Content-Type: application/problem+json
Transfer-Encoding: chunked
Connection: keep-alive
X-Powered-By: PHP/5.5.12-1~dotdeb.1
WWW-Authenticate: Basic realm="api"
这里的错误在哪里?如何让它工作?