POST请求时候,http方法时需要加一些信息到header,而且如果用apache得话,还需要做一些特殊配置来防止apache将认证头丢弃。
或者直接将token值放在url中传递也可以。
不然你就会得到token_absent的错误- -!~
所以,第三方库的使用说明一定要每个字都看清楚,如果不行,那至少要把每行代码都看清楚!
附原文:
To make authenticated requests via http using the built in methods, you will need to set an authorization header as follows:
Authorization: Bearer {yourtokenhere}
Note to Apache users
Apache seems to discard the Authorization header if it is not a base64 encoded user/pass combo. So to fix this you can add the following to your apache config
RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
Alternatively you can include the token via a query string
http://api.mysite.com/me?token={yourtokenhere}