19
19
20
20
# First-Party
21
21
from mcpgateway .db import Gateway , get_db
22
+ from mcpgateway .services .gateway_service import GatewayService
22
23
from mcpgateway .services .oauth_manager import OAuthError , OAuthManager
23
24
from mcpgateway .services .token_storage_service import TokenStorageService
24
25
28
29
29
30
30
31
@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 :
32
33
"""Initiates the OAuth 2.0 Authorization Code flow for a specified gateway.
33
34
34
35
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
37
38
38
39
Args:
39
40
gateway_id: The unique identifier of the gateway to authorize.
40
- request : The FastAPI request object.
41
+ _request : The FastAPI request object.
41
42
db: The database session dependency.
42
43
43
44
Returns:
@@ -80,8 +81,7 @@ async def initiate_oauth_flow(gateway_id: str, request: Request, db: Session = D
80
81
async def oauth_callback (
81
82
code : str = Query (..., description = "Authorization code from OAuth provider" ),
82
83
state : str = Query (..., description = "State parameter for CSRF protection" ),
83
- # Remove the gateway_id parameter requirement
84
- request : Request = None ,
84
+ _request : Request = None ,
85
85
db : Session = Depends (get_db ),
86
86
) -> HTMLResponse :
87
87
"""Handle the OAuth callback and complete the authorization process.
@@ -93,7 +93,7 @@ async def oauth_callback(
93
93
Args:
94
94
code (str): The authorization code returned by the OAuth provider.
95
95
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.
97
97
db (Session): The database session dependency.
98
98
99
99
Returns:
@@ -349,14 +349,14 @@ async def get_oauth_status(gateway_id: str, db: Session = Depends(get_db)) -> di
349
349
"redirect_uri" : oauth_config .get ("redirect_uri" ),
350
350
"message" : "Gateway configured for Authorization Code flow" ,
351
351
}
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
+ }
360
360
361
361
except HTTPException :
362
362
raise
@@ -380,9 +380,6 @@ async def fetch_tools_after_oauth(gateway_id: str, db: Session = Depends(get_db)
380
380
HTTPException: If fetching tools fails
381
381
"""
382
382
try :
383
- # First-Party
384
- from mcpgateway .services .gateway_service import GatewayService
385
-
386
383
gateway_service = GatewayService ()
387
384
result = await gateway_service .fetch_tools_after_oauth (db , gateway_id )
388
385
tools_count = len (result .get ("tools" , []))
0 commit comments