Google Device Access API error : Requested entity was not found

225 Views Asked by At

I have a Google Nest Cam (Battery). I would get the stream live of the cam. I use SDM API and Device Access, but I get this error

Array ( [error] => Array ( [code] => 404 [message] => Requested entity was not found. [status] => NOT_FOUND ) )

I use this code PHP :

$client_id = 'CLIENTID';
$client_secret = 'CLIENTSECRET';
$device_id = 'DEVICEID';
$redirect_uri = 'http://localhost'; // L'URL de redirection que vous avez configurée dans la Console Google Cloud

    $access_token = "ACCESSTOKEN";
    $refresh_token = "REFRESHTOKEN";

    $camera_url = "https://smartdevicemanagement.googleapis.com/v1/enterprises/PROJECT-ID/devices/{$device_id}";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $camera_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Bearer {$access_token}"
]);

$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Erreur cURL : ' . curl_error($ch);
} else {
    $camera_response = json_decode($response, true);
}
curl_close($ch);

print_r($camera_response);

How I can resolve this? I need your help.

I do research in Net., but I doesn't found the source of the problem. All Id-Key is correct.

1

There are 1 best solutions below

0
Siddhant Priyadarshi On

404 means there are not any resources found on the Google side that matches the account used and project id and device id provided. For security reasons when authentication credentials (access token) are not accepted, the system might also show a 404. Within your code you seem to be replacing the device id but you seem to have forgotten to update the project id.