Skip to content

Commit

Permalink
Merge pull request #125 from omarryhan/fix-user-creds-not-found
Browse files Browse the repository at this point in the history
fix user creds not found error in next page iterator
  • Loading branch information
omarryhan authored Sep 2, 2023
2 parents 3728c77 + ab754d1 commit d6b88ae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion aiogoogle/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
__about__ = "Async Google API client"
__description__ = __about__
__url__ = "https://github.com/omarryhan/aiogoogle"
__version_info__ = ("5", "4", "0")
__version_info__ = ("5", "5", "0")
__version__ = ".".join(__version_info__)
__author__ = "Omar Ryhan"
__author_email__ = "[email protected]"
Expand Down
17 changes: 11 additions & 6 deletions aiogoogle/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,17 +348,22 @@ async def _next_page_generator(
)
if next_req is not None:
async with session_factory() as sess:
user_creds = None

if isinstance(prev_res.auth_manager, (ServiceAccountManager, Oauth2Manager)):
authorize_params = [next_req]
is_refreshed = False
user_creds = None

if isinstance(prev_res.auth_manager, ServiceAccountManager):
is_refreshed = await prev_res.auth_manager.refresh()
if is_refreshed:
prev_res.auth_manager.authorize(next_req)
else:
is_refreshed, user_creds = await prev_res.auth_manager.refresh(prev_res.user_creds)
authorize_params.append(user_creds)

if is_refreshed is True:
prev_res.auth_manager.authorize(*authorize_params)
prev_res = await sess.send(next_req, full_res=True, auth_manager=prev_res.auth_manager)
if is_refreshed and user_creds:
prev_res.auth_manager.authorize(next_req, user_creds=user_creds)

prev_res = await sess.send(next_req, full_res=True, auth_manager=prev_res.auth_manager, user_creds=user_creds)
else:
prev_res = None

Expand Down

0 comments on commit d6b88ae

Please sign in to comment.