|
557 | 557 | get_oauth_client_info_with_static_credentials, |
558 | 558 | encrypt_data, |
559 | 559 | decrypt_data, |
| 560 | + resolve_oauth_client_info, |
560 | 561 | OAuthManager, |
561 | 562 | OAuthClientManager, |
562 | 563 | OAuthClientInformationFull, |
@@ -2304,10 +2305,8 @@ async def get_current_usage(user=Depends(get_verified_user)): |
2304 | 2305 | auth_type = tool_server_connection.get('auth_type', 'none') |
2305 | 2306 |
|
2306 | 2307 | if server_id and auth_type in ('oauth_2.1', 'oauth_2.1_static'): |
2307 | | - oauth_client_info = tool_server_connection.get('info', {}).get('oauth_client_info', '') |
2308 | | - |
2309 | 2308 | try: |
2310 | | - oauth_client_info = decrypt_data(oauth_client_info) |
| 2309 | + oauth_client_info = resolve_oauth_client_info(tool_server_connection) |
2311 | 2310 | app.state.oauth_client_manager.add_client( |
2312 | 2311 | f'mcp:{server_id}', |
2313 | 2312 | OAuthClientInformationFull(**oauth_client_info), |
@@ -2368,18 +2367,25 @@ async def register_client(request, client_id: str) -> bool: |
2368 | 2367 |
|
2369 | 2368 | try: |
2370 | 2369 | if auth_type == 'oauth_2.1_static': |
2371 | | - # Static credentials: rebuild from stored credentials + fresh metadata |
2372 | | - existing_client_info = connection.get('info', {}).get('oauth_client_info', '') |
2373 | | - if not existing_client_info: |
2374 | | - log.error(f'No stored OAuth client info for static client {client_id}') |
2375 | | - return False |
2376 | | - existing_data = decrypt_data(existing_client_info) |
| 2370 | + # Static credentials: rebuild from admin-provided credentials + fresh metadata |
| 2371 | + info = connection.get('info', {}) |
| 2372 | + oauth_client_id = info.get('oauth_client_id') or '' |
| 2373 | + oauth_client_secret = info.get('oauth_client_secret') or '' |
| 2374 | + if not oauth_client_id or not oauth_client_secret: |
| 2375 | + # Fall back to blob for backward compatibility |
| 2376 | + existing_client_info = info.get('oauth_client_info', '') |
| 2377 | + if not existing_client_info: |
| 2378 | + log.error(f'No stored OAuth client info for static client {client_id}') |
| 2379 | + return False |
| 2380 | + existing_data = decrypt_data(existing_client_info) |
| 2381 | + oauth_client_id = oauth_client_id or existing_data.get('client_id', '') |
| 2382 | + oauth_client_secret = oauth_client_secret or existing_data.get('client_secret', '') |
2377 | 2383 | oauth_client_info = await get_oauth_client_info_with_static_credentials( |
2378 | 2384 | request, |
2379 | 2385 | client_id, |
2380 | 2386 | server_url, |
2381 | | - oauth_client_id=existing_data.get('client_id', ''), |
2382 | | - oauth_client_secret=existing_data.get('client_secret', ''), |
| 2387 | + oauth_client_id=oauth_client_id, |
| 2388 | + oauth_client_secret=oauth_client_secret, |
2383 | 2389 | ) |
2384 | 2390 | else: |
2385 | 2391 | oauth_client_info = await get_oauth_client_info_with_dynamic_client_registration( |
|
0 commit comments