Nest : getting HTTP/1.1 401 Unauthorized while fetching devices using curl

你离开我真会死。 提交于 2020-01-17 04:59:08

问题


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?


回答1:


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!



来源:https://stackoverflow.com/questions/31676248/nest-getting-http-1-1-401-unauthorized-while-fetching-devices-using-curl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!