Skip to content

Commit e500a8b

Browse files
committed
fix: handle oauth when there is no username saved
1 parent 1dcb165 commit e500a8b

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

yalexs/manager/gateway.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,17 @@ async def async_setup(
8787
brand=self._config.get(CONF_BRAND, DEFAULT_BRAND),
8888
)
8989
klass = authenticator_class or AuthenticatorAsync
90-
access_token_cache_file_path = self.async_configure_access_token_cache_file(
91-
conf[CONF_USERNAME], conf.get(CONF_ACCESS_TOKEN_CACHE_FILE)
92-
)
90+
username = conf.get(CONF_USERNAME)
91+
access_token_cache_file_path: str | None = None
92+
if username:
93+
access_token_cache_file_path = self.async_configure_access_token_cache_file(
94+
conf[CONF_USERNAME], conf.get(CONF_ACCESS_TOKEN_CACHE_FILE)
95+
)
96+
9397
self.authenticator = klass(
9498
self.api,
9599
self._config[CONF_LOGIN_METHOD],
96-
self._config[CONF_USERNAME],
100+
username,
97101
self._config.get(CONF_PASSWORD, ""),
98102
install_id=self._config.get(CONF_INSTALL_ID),
99103
access_token_cache_file=access_token_cache_file_path,
@@ -110,7 +114,9 @@ async def async_authenticate(self) -> Authentication:
110114
# Call the locks api to verify we are actually
111115
# authenticated because we can be authenticated
112116
# by have no access
113-
await self.api.async_get_operable_locks(self.access_token)
117+
await self.api.async_get_operable_locks(
118+
await self.async_get_access_token()
119+
)
114120
except AugustApiAIOHTTPError as ex:
115121
if ex.auth_failed:
116122
raise InvalidAuth from ex

0 commit comments

Comments
 (0)