Skip to main content

How to get access to Google Nest devices using the new API (Google Developers)

 I started a Home Automation project where I divided to replace the custom gateway with Home Assistance. Developing my current IoT platform involves much time and custom development for each device requires too much effort. Because of this, I plan to use Home Assistance as the main hub, combined with Samsung Smartthings Hub for Zigbee and Z-wave integration and Azure Functions. But, this topic is for another article. 

Let's talk now about the Google Developers platform and how to get access to your Nest devices. Google decided to retire the old Nest platform and integrate Nest devices inside Google Home, where Google Nest is now supported.

In the long term, the decision is a smart one because under the same API we can get access to all current and future devices. In the meantime we need to move to the new API and getting access to it is not so easy as we think, even it is well documented. 

To get access to the Google Developer platform you need to pay a small fee (~5$) and be ready to play with Postman if you want to put your hand on the OAuth tokens that are required to access the API. Each step required can be found here - https://developers.google.com/nest/device-access/get-started



Below you can find some tips and tricks for each step:

1. Get Started

1.1. Register for Device Access

You don't need to be an organization, you can use the API for non-commercial use without any reviews from Google. 

1.2. Activate a supported device

-

1.3. Set up Google Cloud Platform

You need to create a project in the Device Access platform before it. At this moment in time, you are able to create only one - https://console.nest.google.com/device-access/project-list 

1.4 Create a Device Access project

Later on, you will need the project ID (UUID). If you forget it or lose you you can go anytime in the project sandbox and copy/paste it using the following link - https://console.nest.google.com/device-access

2. Authorize an Account

2.1. Link your account

At this step, you need to create an OAuth 2.0 Client from API&Services - https://console.developers.google.com/apis/credentials. In most cases, the type of application that you need to create is a Web application. Once you create it, navigate to the OAuth App that you created and ensure that you add 'https://www.google.com/' to the  'Authorised redirect URIs' section. 

The OAuth client ID that you need to specify it is similar with an URL (e.g. 424242dwefdw3f34fwdwd32d23d32.apps.googleusercontent.com/)  and can be copied from the device access projects that you created at step 1.4. 

Once you add the OAuth Client ID and project ID to the URL you can run it inside your browser.

https://nestservices.google.com/partnerconnections/project-id/auth?
redirect_uri=https://www.google.com&
access_type=offline&
prompt=consent&
client_id=oauth2-client-id&
response_type=code&
scope=https://www.googleapis.com/auth/sdm.service

Once you finish the flow, you are redirected to google.com where inside the URL you can find your authorization code. 

https://www.google.com/?code=authorization_code&scope=https://www.googleapis.com/auth/sdm.service

Store the authorization_code because you will need later on.

2.2.Get an access token

During this step, you need to get the access and refresh token. I was not able to run the POST on my local machine using CURL, but I have done this with success using Postman. I recommend using Postman if you have issues at this step.

The POST that I executed from Postman looks as followed

- https://www.googleapis.com/oauth2/v4/token?client_id=[clientID].apps.googleusercontent.com&client_secret=[clientSecret]&code=[code]&grant_type=authorization_code&redirect_uri=https://www.google.com

Save the JSON that was returned because contains the access and refresh token. 

2.3. Make a device list call

You need to run this step to ensure that you activate the access and refresh tokens. From Postman you can run the GET command 

https://smartdevicemanagement.googleapis.com/v1/enterprises/[projectId]/devices

where you set inside the heather:

  • Content-Type as 'application/json'
  • Authorization as 'Bearer [accessToken]', that you got at step 2.3. 
If you get the list of devices in JSON you are done!


Enjoy playing around with the API.


Comments

Popular posts from this blog

How to audit an Azure Cosmos DB

In this post, we will talk about how we can audit an Azure Cosmos DB database. Before jumping into the problem let us define the business requirement: As an Administrator I want to be able to audit all changes that were done to specific collection inside my Azure Cosmos DB. The requirement is simple, but can be a little tricky to implement fully. First of all when you are using Azure Cosmos DB or any other storage solution there are 99% odds that you’ll have more than one system that writes data to it. This means that you have or not have control on the systems that are doing any create/update/delete operations. Solution 1: Diagnostic Logs Cosmos DB allows us activate diagnostics logs and stream the output a storage account for achieving to other systems like Event Hub or Log Analytics. This would allow us to have information related to who, when, what, response code and how the access operation to our Cosmos DB was done. Beside this there is a field that specifies what was th...

Can User Technical Profile Influence AI Architecture Decisions?

In the last few days, I ran a small experiment on Devin/Windsurf/Cascade, BMAD, and LLM-based architecture decisions. The initial concern was simple: if an AI coding assistant knows something about the user, for example, that the user is a Java developer or a .NET developer, can this information influence the architecture and technology stack that the AI will propose? This question is important because many companies are starting to use AI tools not only for coding but also for product discovery, architecture, documentation, and technical decision-making. If the AI is influenced by the developer's personal profile, the result may not be fully neutral. It may look like a business or architecture decision, but in reality, it may be partially shaped by the context of the person using the tool. The test was done using BMAD with Devin/Windsurf/Cascade. The scenario was a unified field service operations platform. The task was to let BMAD refine the product, define the architecture and s...

ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded

Today blog post will be started with the following error when running DB tests on the CI machine: threw exception: System.InvalidOperationException: The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information. at System.Data.Entity.Infrastructure.DependencyResolution.ProviderServicesFactory.GetInstance(String providerTypeName, String providerInvariantName) This error happened only on the Continuous Integration machine. On the devs machines, everything has fine. The classic problem – on my machine it’s working. The CI has the following configuration: TeamCity .NET 4.51 EF 6.0.2 VS2013 It see...