Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix user creds not found error in next page iterator #125

Merged
merged 1 commit into from
Sep 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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