Skip to content

Commit

Permalink
Force re-auth when http status code 400 is returned (#22)
Browse files Browse the repository at this point in the history
* Force re-auth when http status code 400 is returned

* force reauth
  • Loading branch information
arjenbos authored Aug 21, 2024
1 parent c40ae06 commit e72f901
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions custom_components/postnl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,13 @@ async def check_and_refresh_token(self) -> str:
await self.oauth_session.async_ensure_token_valid()
graphql = PostNLGraphql(self.access_token)
await self.oauth_session.hass.async_add_executor_job(graphql.profile)

except (ClientResponseError, ClientError) as exception:
_LOGGER.debug("API error: %s", exception)
if exception.status == 400:
self.oauth_session.config_entry.async_start_reauth(
self.oauth_session.hass
)

raise HomeAssistantError(exception) from exception
except TransportQueryError as exception:
Expand Down

0 comments on commit e72f901

Please sign in to comment.