Skip to content

Commit

Permalink
fix: fix code exchange
Browse files Browse the repository at this point in the history
  • Loading branch information
muhlba91 committed Dec 19, 2023
1 parent 5be6160 commit 7f87813
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions onyx_client/authorizer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async def exchange_code(
client_session: the aiohttp client session to use"""
session = client_session if client_session is not None else aiohttp.ClientSession()
config = await authorize(code, session)
if await OnyxClient(config, session).verify():
if config is not None and await OnyxClient(config, session).verify():
return config
return None

Expand All @@ -35,11 +35,11 @@ async def authorize(
client_session: the aiohttp client session to use"""
async with client_session.post(
f"{API_URL}/authorize",
data={"code": code},
json={"code": code},
headers=API_HEADERS,
) as response:
if not check(response):
_LOGGER.error("Could not authorize client for ONYX API.")
return None
data = await response.json()
return Configuration(data.get("fingerprint", None), data.get("token"))
return Configuration(data.get("fingerprint", None), data.get("token", None))

0 comments on commit 7f87813

Please sign in to comment.