Refresh nest access token before before building subscriber Credentials (#138259)

This commit is contained in:
Allen Porter 2025-02-11 02:51:30 -08:00 committed by Franck Nijhof
parent f8763c49ef
commit 9772014bce
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3

View File

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