Nest Authentication error in logs

I am not sure if this belongs in another forum category (if it does, I’m sorry), but anyway I’ve been having a rough time after re-adding the Nest integration using the new instructions for the SDM API setup.
The setup process was rather messy but in the end I believe everything was set up correctly (even brought up on the Discord server about the additional step needed to add your account as a test user which wasn’t in the original instructions) and the thermostat integration was successfully added to the dashboard.
Which is why I’m confused as to the following error that keeps reappearing in the logs:

Logger: google_nest_sdm.google_nest_subscriber
Source: /usr/local/lib/python3.8/site-packages/google_nest_sdm/google_nest_subscriber.py:192
First occurred: December 30, 2020, 2:18:40 AM (33 occurrences)
Last logged: 2:35:44 PM

Subscriber disconnected, will restart: <class 'google.api_core.exceptions.Unauthenticated'>: 401 Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.

I double-checked the required entries in configuration.yaml against all of the various Google console windows and they line up (OAuth client ID & secret, Project ID from Device Access Console, and Subscriber ID from the Pub/Sub API page) and they had to have worked from the start because the integration was added successfully in the first place (if there was an authorization issue I should’ve been stopped there, right?)

Anyone have any ideas on what to check for this?

Can you control it via HA? If so, then that’s just something you can remove by configuring logger.

Did not know about the logger function, that’s good to know.
So you’re saying as long as the control is working, then it’s just a non-issue? Because 401 invalid authentication seems sus to me, especially after the messy process it takes to set it up in the first place.

It is an issue, but you can just put a :adhesive_bandage: on it in the logger config if it’s a minor problem.

Hi,
I added this log line and summary is there is no need to worry about this for multiple reasons both short term and long term. It has been removed from the 2021.01 release to reduce confusion and future releases entirely change how auth works so this particular code path won’t be happening anyway. Sorry for the noise. (Happy to go in great detail if you want more info, or you can find the github issues with lots of background)

Oh ok cool! I just wanted to check in on it as I wasn’t able to find documentation concerning it and I know it’s an ongoing process with that integration, but if it’s not causing unknown issues then I can just strike that from the logs (as well as a couple others, now that I know about that :slightly_smiling_face:)

1 Like

I’m having this same problem. Will fix it with adjusting logger.

I’m seeing the same log, but I am noticing that Home Assistant is not picking up changes, unless I go and wave in front of the Thermostat, so the screen turns on.

For me, I can see the current temperature on the main page and control it. However, my Grafana graphs don’t update with new temperatures, unless I awaken the Nest, or access the “widget” in Home Assistant.

So, it seems the error is correct, I’m not getting the sub/pub notifications for some reason…

Any ideas?

That error does not affect functionality, plus as I mentioned it’s already been changed in the next releases.

I haven’t heard of that symptom before. If your thermostat is not sending updates unless you wake it up that sounds like an entirely different problem not related to home assistant? That is, home assistant gets the updates when you wake it up so home assistant is working.

Spoke too soon: now the integration isn’t working.

Logger: homeassistant.components.websocket_api.http.connection
Source: components/nest/climate_sdm.py:300
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 8:29:55 PM (1 occurrences)
Last logged: 8:29:55 PM

[1876802168] Access token failure: 400, message='Bad Request', url=URL('https://www.googleapis.com/oauth2/v4/token')
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/google_nest_sdm/auth.py", line 43, in request
    access_token = await self.async_get_access_token()
  File "/usr/src/homeassistant/homeassistant/components/nest/api.py", line 28, in async_get_access_token
    await self._oauth_session.async_ensure_token_valid()
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 465, in async_ensure_token_valid
    new_token = await self.implementation.async_refresh_token(self.token)
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 84, in async_refresh_token
    new_token = await self._async_refresh_token(token)
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 175, in _async_refresh_token
    new_token = await self._token_request(
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 194, in _token_request
    resp.raise_for_status()
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 1002, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 400, message='Bad Request', url=URL('https://www.googleapis.com/oauth2/v4/token')

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 135, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1445, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1480, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 593, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 664, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 630, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/nest/climate_sdm.py", line 300, in async_set_hvac_mode
    await trait.set_mode(api_mode)
  File "/usr/local/lib/python3.8/site-packages/google_nest_sdm/thermostat_traits.py", line 94, in set_mode
    return await self._cmd.execute(data)
  File "/usr/local/lib/python3.8/site-packages/google_nest_sdm/traits.py", line 19, in execute
    resp = await self._auth.request(
  File "/usr/local/lib/python3.8/site-packages/google_nest_sdm/auth.py", line 45, in request
    raise AuthException(f"Access token failure: {err}") from err
google_nest_sdm.exceptions.AuthException: Access token failure: 400, message='Bad Request', url=URL('https://www.googleapis.com/oauth2/v4/token')

I saw that. I’m using HASS.io, so will hopefully see it when the release is pushed out.


I’m not sure actually. I left the thermostats alone, and over a period of 8 hours, I got 9 updates from the Upstairs thermostat, but only 2 from the Downstairs thermostats. With the kids home from school, they walk passed the upstairs thermostat much more often than we would trigger the Downstairs one, but this is pure speculation at this point.

I have no idea how to debug this. I obviously get temperatures from both, but it doesn’t seem to be as often as it should. You can see the temperature changes for Downstairs being ~1F between updates, while Upstairs is smaller changes.

But, you’re right, this is probably completely unrelated to Pub/Sub, but more about how Nest actually works?

See https://www.home-assistant.io/integrations/nest/#troubleshooting including the View Messages section which tells how to better understand what the system is doing on the Nest side from the cloud console.

View Messages is empty for me, but I believe that Ack’ed messages are purged, right?

Anyways, I see the following:
(1)
And I’m surprised to see “sdm-prod” instead of “nestaccessproject” in the Topic name URL, is that correct?

And if you see my Role/Member permissions on the right-hand side, I’ve given my user all roles and access, but when I click on the “Topic name” URL, I get the following:
(2)

And even if I switch the project, I cannot seem to get the list of topics:
(3)

Which I don’t get, since my user is the Owner of the project? What am I missing here?

The topic is correct in sdm-projects, it’s owned by the device access project and not your cloud project. Looks like everything is fine

It’s been working well for about a week, but just now it started complaining that the Nest integration has to be reconfigured. I haven’t changed anything. Any idea why this is suddenly failing?

Do the entities not work?

Nope, not anymore…

…and now the Auth failure changed from internal IP to internal hostname for some reason, even though I do have the external hostname set to nabu.casa…

I’m fairly confident it’s something to do with an access token issue, as detailed from my previous error log post. The integration works for a while, and then after a period of time authentication fails and you have to re-up it. An expired token is making the most sense to me right now (and it just happened again to me).
Are there any further updates concerning this issue?

I am experiencing this issue as well, the authentification expires after exactly 7 days. This happens every time if I check te logs I don’t see anything other then an authentification failure.