Nest:在使用curl获取设备时获取HTTP / 1.1 401未经授权

时间:2015-07-28 12:24:23

标签: rest curl firebase nest-api firebase-authentication

如果我想使用

获取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> 

然后用HTTP / 1.1 200 OK回复,我认为是正确的AUTHCODE。再次提到我的帐户中没有任何设备。

所以我得到的回应有所不同。我的问题是,为什么我得到401 Unauthorized而不是404找不到或200 ok第一个curl命令?

1 个答案:

答案 0 :(得分:2)

我发现如果我使用了您提供的网址:

    https://developer-api.nest.com/devices?auth=<AUTHCODE>

但也包含在标题中:

    Authorization: Bearer <AUTHCODE>
    Content-Type: application/json
然后它似乎工作了!

相关问题