Skip to content

Commit

Permalink
Don't pass otp param if None is supplied
Browse files Browse the repository at this point in the history
  • Loading branch information
LilSpazJoekp committed Jun 15, 2021
1 parent f799644 commit 0ebee4d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion asyncprawcore/auth.py
Expand Up @@ -372,14 +372,17 @@ def __init__(self, authenticator, username, password, two_factor_callback=None):

async def refresh(self):
"""Obtain a new personal-use script type access token."""
additional_kwargs = {}
if self._two_factor_callback:
if inspect.iscoroutinefunction(self._two_factor_callback):
otp = await self._two_factor_callback()
else:
otp = self._two_factor_callback()
if otp:
additional_kwargs["otp"] = otp
await self._request_token(
grant_type="password",
username=self._username,
password=self._password,
otp=self._two_factor_callback and otp,
**additional_kwargs,
)

0 comments on commit 0ebee4d

Please sign in to comment.