diff --git a/a2a/weather_service/src/weather_service/agent.py b/a2a/weather_service/src/weather_service/agent.py index 763dc09..6e872b6 100644 --- a/a2a/weather_service/src/weather_service/agent.py +++ b/a2a/weather_service/src/weather_service/agent.py @@ -94,6 +94,10 @@ async def execute(self, context: RequestContext, event_queue: EventQueue): """ The agent allows to retrieve weather info through a natural language conversational interface """ + + # Log authorization header for debugging + auth_header = context.call_context.get("authorization") if hasattr(context, 'call_context') else None + logger.info(f"🔐 Authorization header received: {auth_header[:50] + '...' if auth_header and len(auth_header) > 50 else auth_header}") # Setup Event Emitter task = context.current_task @@ -165,5 +169,15 @@ def run(): agent_card=agent_card, http_handler=request_handler, ) - - uvicorn.run(server.build(), host="0.0.0.0", port=8000) + + # Add middleware to log all incoming requests with headers + app = server.build() + + @app.middleware("http") + async def log_authorization_header(request, call_next): + auth_header = request.headers.get("authorization", "No Authorization header") + logger.info(f"🔐 Incoming request to {request.url.path} with Authorization: {auth_header[:80] + '...' if len(auth_header) > 80 else auth_header}") + response = await call_next(request) + return response + + uvicorn.run(app, host="0.0.0.0", port=8000)