Nest:在使用curl获取设备时获取HTTP / 1.1 401未授权 [英] Nest : getting HTTP/1.1 401 Unauthorized while fetching devices using curl

查看:751
本文介绍了Nest:在使用curl获取设备时获取HTTP / 1.1 401未授权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我想使用

 取得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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆