Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions a2a/weather_service/src/weather_service/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)