Skip to content

Commit 492f406

Browse files
authored
Update base_push_notification_sender.py
- Honor PushNotificationConfig.authentication field in BasePushNotificationSender - Add Authorization header when Bearer scheme is configured - Maintain backward compatibility with existing X-A2A-Notification-Token header
1 parent 3deecc4 commit 492f406

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/a2a/server/tasks/base_push_notification_sender.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,21 @@ async def _dispatch_notification(
5252
) -> bool:
5353
url = push_info.url
5454
try:
55-
headers = None
55+
headers = {}
5656
if push_info.token:
57-
headers = {'X-A2A-Notification-Token': push_info.token}
57+
headers['X-A2A-Notification-Token'] = push_info.token
58+
59+
# Add authentication header if configured
60+
if push_info.authentication and push_info.authentication.schemes:
61+
for scheme in push_info.authentication.schemes:
62+
if scheme.lower() == 'bearer' and push_info.authentication.credentials:
63+
headers['Authorization'] = f'Bearer {push_info.authentication.credentials}'
64+
break
65+
5866
response = await self._client.post(
5967
url,
6068
json=task.model_dump(mode='json', exclude_none=True),
61-
headers=headers,
69+
headers=headers if headers else None,
6270
)
6371
response.raise_for_status()
6472
logger.info(

0 commit comments

Comments
 (0)