1919
2020# First-Party
2121from mcpgateway .db import Gateway , get_db
22+ from mcpgateway .services .gateway_service import GatewayService
2223from mcpgateway .services .oauth_manager import OAuthError , OAuthManager
2324from mcpgateway .services .token_storage_service import TokenStorageService
2425
2829
2930
3031@oauth_router .get ("/authorize/{gateway_id}" )
31- async def initiate_oauth_flow (gateway_id : str , request : Request , db : Session = Depends (get_db )) -> RedirectResponse :
32+ async def initiate_oauth_flow (gateway_id : str , _request : Request , db : Session = Depends (get_db )) -> RedirectResponse :
3233 """Initiates the OAuth 2.0 Authorization Code flow for a specified gateway.
3334
3435 This endpoint retrieves the OAuth configuration for the given gateway, validates that
@@ -37,7 +38,7 @@ async def initiate_oauth_flow(gateway_id: str, request: Request, db: Session = D
3738
3839 Args:
3940 gateway_id: The unique identifier of the gateway to authorize.
40- request : The FastAPI request object.
41+ _request : The FastAPI request object.
4142 db: The database session dependency.
4243
4344 Returns:
@@ -80,8 +81,7 @@ async def initiate_oauth_flow(gateway_id: str, request: Request, db: Session = D
8081async def oauth_callback (
8182 code : str = Query (..., description = "Authorization code from OAuth provider" ),
8283 state : str = Query (..., description = "State parameter for CSRF protection" ),
83- # Remove the gateway_id parameter requirement
84- request : Request = None ,
84+ _request : Request = None ,
8585 db : Session = Depends (get_db ),
8686) -> HTMLResponse :
8787 """Handle the OAuth callback and complete the authorization process.
@@ -93,7 +93,7 @@ async def oauth_callback(
9393 Args:
9494 code (str): The authorization code returned by the OAuth provider.
9595 state (str): The state parameter for CSRF protection, which encodes the gateway ID.
96- request (Request): The incoming HTTP request object.
96+ _request (Request): The incoming HTTP request object.
9797 db (Session): The database session dependency.
9898
9999 Returns:
@@ -349,14 +349,14 @@ async def get_oauth_status(gateway_id: str, db: Session = Depends(get_db)) -> di
349349 "redirect_uri" : oauth_config .get ("redirect_uri" ),
350350 "message" : "Gateway configured for Authorization Code flow" ,
351351 }
352- else :
353- return {
354- "oauth_enabled" : True ,
355- "grant_type" : grant_type ,
356- "client_id" : oauth_config .get ("client_id" ),
357- "scopes" : oauth_config .get ("scopes" , []),
358- "message" : f"Gateway configured for { grant_type } flow" ,
359- }
352+
353+ return {
354+ "oauth_enabled" : True ,
355+ "grant_type" : grant_type ,
356+ "client_id" : oauth_config .get ("client_id" ),
357+ "scopes" : oauth_config .get ("scopes" , []),
358+ "message" : f"Gateway configured for { grant_type } flow" ,
359+ }
360360
361361 except HTTPException :
362362 raise
@@ -380,9 +380,6 @@ async def fetch_tools_after_oauth(gateway_id: str, db: Session = Depends(get_db)
380380 HTTPException: If fetching tools fails
381381 """
382382 try :
383- # First-Party
384- from mcpgateway .services .gateway_service import GatewayService
385-
386383 gateway_service = GatewayService ()
387384 result = await gateway_service .fetch_tools_after_oauth (db , gateway_id )
388385 tools_count = len (result .get ("tools" , []))
0 commit comments