问题
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