Skip to content

Commit

Permalink
Updated auth_callback to be handled based on async/blocking implement…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
sacOO7 committed Oct 1, 2023
1 parent 274e956 commit 0f777c9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ably/rest/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,13 @@ async def request_token(self, token_params: Optional[dict] = None,
log.debug("Token Params: %s" % token_params)
if auth_callback:
log.debug("using token auth with authCallback")
# handle auth_callback in accordance with async/blocking nature of the implementation
try:
token_request = await auth_callback(token_params)
res = auth_callback(token_params)
if asyncio.iscoroutine(res):
token_request = await res
else:
token_request = res
except Exception as e:
raise AblyException("auth_callback raised an exception", 401, 40170, cause=e)
elif auth_url:
Expand Down

0 comments on commit 0f777c9

Please sign in to comment.