@@ -403,7 +403,7 @@ def get_redirect_uri(self, token_type: str = 'main') -> str: # pylint: disable=
403
403
return f'http://localhost:{ port } /{ redirect_path } '
404
404
405
405
@staticmethod
406
- async def handle_oauth_redirect (request , oauth_config : dict ):
406
+ async def handle_oauth_redirect (request , oauth_config : dict , config , jinja2_env ):
407
407
"""Generic OAuth2 redirect handler for any service.
408
408
409
409
This method handles the OAuth2 authorization code flow redirect for any service.
@@ -420,12 +420,14 @@ async def handle_oauth_redirect(request, oauth_config: dict):
420
420
- 'redirect_path': Path component for redirect URI (e.g., 'kickredirect')
421
421
- 'token_keys': Dict with 'access' and 'refresh' keys for token storage
422
422
- 'success_template': Success template name (optional)
423
+ config: The config object (nowplaying.config.ConfigFile)
424
+ jinja2_env: The Jinja2 environment (jinja2.Environment)
423
425
424
426
Returns:
425
427
aiohttp.web.Response: HTML response for the OAuth flow result
426
428
"""
427
429
# Initialize helper
428
- helper = _OAuthRedirectHelper (request , oauth_config )
430
+ helper = _OAuthRedirectHelper (request , oauth_config , config , jinja2_env )
429
431
430
432
# Process OAuth flow steps
431
433
if error_response := helper .handle_oauth_error ():
@@ -441,7 +443,7 @@ async def handle_oauth_redirect(request, oauth_config: dict):
441
443
class _OAuthRedirectHelper : # pylint: disable=too-many-instance-attributes
442
444
"""Helper class to handle OAuth redirect processing steps."""
443
445
444
- def __init__ (self , request : web .Request , oauth_config : dict ):
446
+ def __init__ (self , request : web .Request , oauth_config : dict , config , jinja2_env ):
445
447
self .request = request
446
448
self .oauth_config = oauth_config
447
449
self .params = dict (request .query )
@@ -457,10 +459,9 @@ def __init__(self, request: web.Request, oauth_config: dict):
457
459
self .success_template = oauth_config .get ('success_template' ,
458
460
f"{ oauth_config ['template_prefix' ]} _success.htm" )
459
461
460
- # Get app context - use string constants to avoid circular import
461
- self .config = request . app [ ' config' ]
462
+ # Use provided config and jinja2 environment
463
+ self .config = config
462
464
self .config .get ()
463
- jinja2_env = request .app ['jinja2' ]
464
465
self .load_template = self ._create_template_loader (jinja2_env )
465
466
466
467
# Log redirect for debugging (don't log auth code for security)
0 commit comments