最佳答案
我正在学习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=
是基于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"
这里的错误在哪里?如何让它工作?