Last active
January 15, 2020 04:38
-
-
Save gboudreau/8b8851a9c99140b6234856bbc80a2d24 to your computer and use it in GitHub Desktop.
Manually create cache file required for nest-api to work with Nest accounts (not Google accounts). Ref: https://github.com/gboudreau/nest-api/issues/110
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
echo "\nInstructions:\n"; | |
echo " - Login to https://home.nest.com in your browser\n"; | |
echo " - Once logged in, using the same tab, go to https://home.nest.com/session\n"; | |
echo " - Copy-paste the text (JSON) here (then press ENTER):\n\n"; | |
$json = readline(); | |
$o = json_decode($json); | |
echo "\nThanks!\n\n"; | |
$username = readline("What is your Nest username: "); | |
$password = readline("What is your Nest password: "); | |
$cache_file = sys_get_temp_dir() . '/nest_php_cache_' . md5($username . $password); | |
echo "\nWill create cache file at $cache_file ...\n"; | |
$vars = array( | |
'transport_url' => $o->urls->transport_url, | |
'access_token' => $o->access_token, | |
'user' => $o->user, | |
'userid' => $o->userid, | |
'cache_expiration' => strtotime($o->expires_in) | |
); | |
file_put_contents($cache_file, serialize($vars)); | |
echo "Done.\n"; | |
echo "Access token will expire on $o->expires_in. You will need to re-execute this script before then.\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment