2.4 KiB
+++ title = "Nest Thermostat Logger" date = 2022-12-24 draft = true
[taxonomies] tags = ["Nest", "Google", "API", "DeviceAccess", "OAuth2", "Temperature", "Humidity", "Weather"] +++
Since Works with Nest (WWN) is retiring, I decided to get set up on Device Access to check out the Smart Device Management (SDM) API. The Quick Start Guide on the Device Access page is very comprehensive, and here's what I did to get everything up and running.
First I paid the seemingly unavoidable one-time, non-refundable $5 USD fee and accepted both the Google API and Device Access Sandbox Terms of Service.
Since access to the SDM API is through Google Cloud Platform (GCP) I created a project and enabled the Smart Device Management API from the API Enablement page and created an OAuth 2.0 Client ID on the Credentials page.
My final step in setup was to create a project in Device Access, so I have the Project UUID needed to make SDM API calls.
Authorizing an account through this link allows granting access to my nest:
This redirects to google.com and returns the authorization code in the address bar:
https://www.google.com?code=authorization-code&scope=https://www.googleapis.com/auth/sdm.service
This curl request returns the access and refresh tokens:
$ curl -L -X POST 'https://www.googleapis.com/oauth2/v4/token?client_id=oauth2-client-id&client_secret=oauth2-client-secret&code=authorization-code&grant_type=authorization_code&redirect_uri=https://www.google.com'