Skip to content

Commit

Permalink
Fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
msvisser committed Jan 20, 2025
1 parent dbaf8d8 commit 5719b7e
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions custom_components/remeha_home/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,24 +295,23 @@ async def async_generate_authorize_url(self, flow_id: str) -> str:

async def _async_request_new_token(self, grant_params):
"""Call the OAuth2 token endpoint with specific grant paramters."""
async with asyncio.timeout(30):
async with self._session.post(
"https://remehalogin.bdrthermea.net/bdrb2cprod.onmicrosoft.com/oauth2/v2.0/token?p=B2C_1A_RPSignUpSignInNewRoomV3.1",
data=grant_params,
allow_redirects=True,
) as response:
# NOTE: The OAuth2 token request sometimes returns a "400 Bad Request" response. The root cause of this
# problem has not been found, but this workaround allows you to reauthenticate at least. Otherwise
# Home Assitant would get stuck on refreshing the token forever.
if response.status == 400:
response_json = await response.json()
_LOGGER.error(
"OAuth2 token request returned '400 Bad Request': %s",
response_json["error_description"],
)
raise ConfigEntryAuthFailed

response.raise_for_status()
async with asyncio.timeout(30), self._session.post(
"https://remehalogin.bdrthermea.net/bdrb2cprod.onmicrosoft.com/oauth2/v2.0/token?p=B2C_1A_RPSignUpSignInNewRoomV3.1",
data=grant_params,
allow_redirects=True,
) as response:
# NOTE: The OAuth2 token request sometimes returns a "400 Bad Request" response. The root cause of this
# problem has not been found, but this workaround allows you to reauthenticate at least. Otherwise
# Home Assitant would get stuck on refreshing the token forever.
if response.status == 400:
response_json = await response.json()
_LOGGER.error(
"OAuth2 token request returned '400 Bad Request': %s",
response_json["error_description"],
)
raise ConfigEntryAuthFailed

response.raise_for_status()
response_json = await response.json()

return response_json

0 comments on commit 5719b7e

Please sign in to comment.