Skip to content

Commit 3578f4e

Browse files
authored
Refresh nest access token before before building subscriber Credentials (#138259)
1 parent 0d605f9 commit 3578f4e

File tree

1 file changed

+8
-7
lines changed
  • homeassistant/components/nest

1 file changed

+8
-7
lines changed

homeassistant/components/nest/api.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,14 @@ async def async_get_access_token(self) -> str:
5050
return cast(str, self._oauth_session.token["access_token"])
5151

5252
async def async_get_creds(self) -> Credentials:
53-
"""Return an OAuth credential for Pub/Sub Subscriber."""
54-
# We don't have a way for Home Assistant to refresh creds on behalf
55-
# of the google pub/sub subscriber. Instead, build a full
56-
# Credentials object with enough information for the subscriber to
57-
# handle this on its own. We purposely don't refresh the token here
58-
# even when it is expired to fully hand off this responsibility and
59-
# know it is working at startup (then if not, fail loudly).
53+
"""Return an OAuth credential for Pub/Sub Subscriber.
54+
55+
The subscriber will call this when connecting to the stream to refresh
56+
the token. We construct a credentials object using the underlying
57+
OAuth2Session since the subscriber may expect the expiry fields to
58+
be present.
59+
"""
60+
await self.async_get_access_token()
6061
token = self._oauth_session.token
6162
creds = Credentials( # type: ignore[no-untyped-call]
6263
token=token["access_token"],

0 commit comments

Comments
 (0)