Nest Authorization Error Error 400: invalid_request

It doesn’t expire because you app is published.

My published App Auth configured integration did expire after 7-10 days and I had to re-auth, which isn’t difficult but is annoying. Flip back to testing and re-auth.

it will stop working in October

Can someone link to this?

I found the page and video to set this up for my Nest thermostats and after getting the same Error 400 I found this thread. I am not using docker, so I’m hoping Google fixes the auth error with Nest. If someone finds an answer please be sure to update here so we all get notified :slight_smile:

Have just attempted this myself having made the plunge to finally migrate today (seems I should’ve checked for prior errors first, but hey-ho…).

Seems that updates aren’t getting pushed along the Pub/Sub — the Thermostat doesn’t show any change since first configured. Have you encountered any similar issues?

Nnnnneevermind. I dun goofed.

Put the wrong Subscriber Name in (had two projects, one for the prior “App” based auth flow).

Thanks so much for this post, JamesDeng, it finally worked for me using this method. I had first tried the current instructions on the HA website and got stuck with the 400 error, but how after changing the things to follow these old instructions, its finally integrated. Now I just have to figure out how to get some automations going.

Signed up to say I had the same error. I have been dragging my feet to jump over to this integration for a few years now and then ran into the same problem.

For those that have means of owning a custom domain name and have HTTPS enabled on Home Assistant with that domain name; the answer is to switch to Web API auth (regardless if using Docker or not). You do not need to expose Home Assistant to the internet, but once google authenticates your request, the redirect URL from their login page needs to match the domain name you are using in your environment.

If you have a domain name and a certificate, you can use these quick steps:

Create and configure Cloud Project [Cloud Console]
Follow steps as currently documented

New Step - Register Cloud Pub/Sub API
You will need a second feature registered in your Google Project for this method. Register the Cloud Pub/Sub API You can do that by navigating to this link and clicking the enable button: Google Cloud Platform

Configure OAuth Consent screen [Cloud Console] Follow as-is

Configure OAuth client_id and client_secret [Cloud Console]:
Follow steps 1 and 2 as currently documented
Step 3: Set the Application Type to Web Application
Step 4: Pick a name for your credential.
Step 5: Click Add URI
Step 6: Add the following URI (substitute your domain name): https://yourdomainname.com/auth/external/callback
Step 7: Click Create

Create a Device Access project_id [Device Access Console]
Follow steps as currently documented

Hope this helps!

5 Likes

Can you tell me how to generate a new access token/authorisation code please ? At the moment I am deleting the old project and starting from the beginning each time.

When HA says there is a problem, Set your Google Cloud Console project back to testing and go through the reauth process through HA. Then set back to Publish. You have to wait for HA to say there is a problem. I find that changing my Nest temp will trigger the reauth in HA.

1 Like

And now my steps above are no longer working. I get “Unknown error occurred”

Thank you @JamesDeng!! Your instructions worked for me.

Question: For Nabu Casa users, where do we find the unique external url? In the Mobile Home Assistant Companion, under External URL, it just says “Home Assistant Cloud” (see screenshot).

I’m assuming I need to insert something unique, where the “xxx” are in the example template url here:

https://xxx.ui.nabu.casa/auth/external/callback

Found it. Was looking in the wrong place. For anyone else, it’s under the Home Assistant Cloud section… right where it should be (screenshot included).

JamesDeng. Thank u! This worked for me.

Hi All, I’m trying the custom component version of this hack, and finding that my climate entities (but not the temperature and humidity entities) for my thermostats are missing. Any idea why??

UPDATE: following Shane’s comment below, I’ve updated the ghclone command to clone the master rather than dev branch. After this, the climate entities work once again.

Where what I did:

  1. Cloned the nest integration as a custom component
cd config/custom_components
pip install github-clone
ghclone https://github.com/home-assistant/core/tree/master/homeassistant/components/nest
  1. Then I edited the const.py file, AND added a version field to the manifest.json file. Without the latter edit, the custom component was not recognized. It’s not enough to copy the core integration, you MUST add a version field.

  2. Restarted HA and installed the new (overridden, custom) nest component.

  3. Copied out the code string from the resulting URL.

As a result, my temperature and humidity entities work, but my climate entities do not. So I can see the temperatures, but I can’t adjust the thermostat. :confused:

Any ideas what might be going on?

1 Like

Could you help me with the field in create subscription “create a cloud sub/pub topic”? It’s saying to take it from the device access page, but doesn’t make sense to me with the format it requires. The example links are dead. Thank you in advance.

Thank you so much finally got it to work with your instructions and some additional changes!!!

@JamesDeng Thank you for these detailed instructions. I was getting “404 invalid_request” errors authenticating with the Desktop App OAuth method, but your walk-through using the Web App allowed me to get the Nest integration working in Home Assistant.

I tried adding the version field. This actually got me closer than ever before to getting this integration to work, as now the URL has the “http://localhost:1” in it, however when I paste the code from the URL, it loads for much longer than before but still gives me the Unknown Error. Is there anything I could be doing wrong here? I’ll keep trying different things.

@danhiking I made an account just to post this.

I found myself in the same place you were, working connection through the localhost work-around, but only humidity and temperature entities viable, no climate entity.

After reading through some logs I noticed some odd error messages, of why the climate entity couldnt be setup, almost as if it was using the wrong file path to start it.

I believe this PR’s usage of EntityFeature enums combined with our usage of custom_components, causes problems. However that’s only my working theory

But I did get the climate working and can now control the temperature !!

I followed all your same steps in your post, however I cloned the “master” branch vs the “dev” branch that you cloned for the nest component.

Thought I would share for you and others ! Hopes this helps !

I was able to get this component installed fine. However, when I go to “configure” the resulting redirect page is still a google auth error page with a “Error 400: redirect_uri_mismatch”:

If you’re the app developer, make sure that these request details comply with Google policies.

* redirect_uri: http://localhost:1

The URL does not contain a code parameter either. Any ideas what I have done incorrectly here?