Nest:在使用curl获取设备时获取HTTP / 1.1 401未授权 [英] Nest : getting HTTP/1.1 401 Unauthorized while fetching devices using curl
问题描述
如果我想使用
取得Nest装置,我会收到HTTP / 1.1 401未经授权?curl -v -L https ://developer-api.nest.com/devices/?auth =< AUTHCODE>
我的Nest帐户中没有任何设备。我想我应该得到HTTP / 1.1 404 Not Found。
我试图用此命令获取恒温器
curl -v -L https://developer-api.nest.com/devices/thermostats?auth=<AUTHCODE>
然后它用相同的AUTHCODE回复HTTP / 1.1 200 OK,我认为是正确的。再次提到我的帐户中没有任何设备。
因此我的回复有所不同。我的问题是,为什么我获得401未授权,而不是404未找到或第一个curl命令200确定?
发现如果我使用您提供的网址:
https://developer-api.nest.com/devices?auth= < AUTHCODE>
,但也包含在标题中:
授权:承载< AUTHCODE>
Content-Type:application / json
I'm getting HTTP/1.1 401 Unauthorized if I want to fetch Nest devices using
curl -v -L https://developer-api.nest.com/devices/?auth=<AUTHCODE>
I don't have any device in my Nest account. I think I should get HTTP/1.1 404 Not Found.
I tried to fetch thermostats with this command
curl -v -L https://developer-api.nest.com/devices/thermostats?auth=<AUTHCODE>
then it replies back with HTTP/1.1 200 OK with same AUTHCODE which I think is correct. Again mentioning that I don't have any device in my account.
So there is difference in the response that I'm getting. My question is that why am I getting 401 Unauthorized instead of 404 not found or 200 ok for the first curl command?
I found that if I used the URL you gave:
https://developer-api.nest.com/devices?auth=<AUTHCODE>
but also included into the headers:
Authorization: Bearer <AUTHCODE>
Content-Type: application/json
then it seemed to work!
这篇关于Nest:在使用curl获取设备时获取HTTP / 1.1 401未授权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!