-2

I try to use API Nest for Nest Outdoor Cam, but I get a error.

I use this code PHP:

$url = "https://developer-api.nest.com/devices/cameras/".$deviceid."/is_online";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
$data = curl_exec($curl);

if(curl_errno($curl)) {
    echo "Erreur cURL : " . curl_error($curl);
}

curl_close($curl);
echo("Online : ".$data);

When I run the code :

Online : {"error":"unauthorized","type":"https://developer.nest.com/documentation/cloud/error-messages#auth-error","message":"unauthorized","instance":"92045a0b-1683-4d6f-bcd3-0c298916f40f"}

I need your help.

You can see the code and the result in top

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • Which part of `unauthorized` are you confused about? – ADyson Aug 31 '23 at 07:47
  • https://developers.nest.com/guides/api/authorization-overview – ADyson Aug 31 '23 at 07:49
  • P.S. That documentation appears to be saying that it will all be switched off in a month's time...you might be a bit late to the party. – ADyson Aug 31 '23 at 07:49
  • @ADyson Oh no. How i will do after a month for use API? I need your help for find why i get this error and how i can solve this? – Egen Roanne Aug 31 '23 at 07:59
  • You get the error because you haven't authorised the request. Read the documentation I provided above - all requests require an access token. The documentation shows you how to set your application up to obtain one, and then use it in an API request. – ADyson Aug 31 '23 at 08:04
  • `How i will do after a month`...again, read the documentation: https://developers.nest.com/ and https://support.google.com/googlenest/answer/9293712 – ADyson Aug 31 '23 at 08:04
  • @ADyson Thanks a lot for the document. Now, I have another problem. I can't log in Nest – Egen Roanne Aug 31 '23 at 08:07
  • Again, did you read the documentation _in full_? I don't think you've had time to do that yet. https://support.google.com/googlenest/answer/9293712 says that the Nest API requires that you had an account set up with Nest before 2019. Did you have that? – ADyson Aug 31 '23 at 08:08
  • @ADyson I get this error : Access blocked: the request for this app is invalid Xxx@gmail.com You can't sign in because this app sent an invalid request. You can try again later or contact the developer about this issue. Learn more about this error If you are one of the developers of this app, view the error details. Error 400: redirect_uri_mismatch – Egen Roanne Aug 31 '23 at 08:08
  • @ADyson So I can't use the API? – Egen Roanne Aug 31 '23 at 08:10
  • Probably not. But...what would be the point of making the effort anyway? You'll only have it for a month. Follow that last link instead to read about the alternative options for interacting with your Nest device. – ADyson Aug 31 '23 at 08:10
  • No problem. But this info was all visible on the API documentation _before_ you started your work. Always take the time to read everything fully before starting to code :-) – ADyson Aug 31 '23 at 08:16
  • @ADyson You're right. – Egen Roanne Aug 31 '23 at 08:22

0 Answers0