Skip to content

Commit 76ec7c3

Browse files
authored
Merge pull request #60 from maia-iyer/remove_weather_auth
🐛 Remove auth code in weather agent
2 parents 3a68555 + f9ff732 commit 76ec7c3

1 file changed

Lines changed: 0 additions & 41 deletions

File tree

  • a2a/weather_service/src/weather_service

a2a/weather_service/src/weather_service/agent.py

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -88,38 +88,6 @@ async def emit_event(self, message: str, final: bool = False, failed: bool = Fal
8888
),
8989
)
9090

91-
def get_token() -> str:
92-
keycloak_url = os.getenv("KEYCLOAK_URL", "http://keycloak.localtest.me:8080")
93-
client_id = os.getenv("CLIENT_NAME", "NOTSET")
94-
realm_name = "master"
95-
client_secret = os.getenv("CLIENT_SECRET")
96-
97-
user_username = "test-user"
98-
user_password = "test-password"
99-
100-
# print(f"client_id: {client_id}")
101-
logger.info(
102-
f"Using client_id='{client_id}' with realm={realm_name}"
103-
)
104-
105-
try:
106-
keycloak_openid = KeycloakOpenID(server_url=keycloak_url,
107-
client_id=client_id,
108-
realm_name=realm_name,
109-
client_secret_key=client_secret)
110-
111-
access_token = keycloak_openid.token(
112-
username=user_username,
113-
password=user_password)
114-
except Exception as e:
115-
raise Exception(f"Authorization error getting the access token: {e}")
116-
117-
logger.info(
118-
f"Received access token: {access_token}"
119-
)
120-
return access_token
121-
122-
12391
class WeatherExecutor(AgentExecutor):
12492
"""
12593
A class to handle weather assistant execution for A2A Agent.
@@ -144,15 +112,6 @@ async def execute(self, context: RequestContext, event_queue: EventQueue):
144112

145113
task_updater = TaskUpdater(event_queue, task.id, task.context_id)
146114

147-
# demo - if keycloak is enabled, try to acquire token
148-
try:
149-
if os.getenv("KEYCLOAK_URL"):
150-
token = get_token()
151-
logger.info(f'received token: {token}')
152-
except Exception as e:
153-
await event_emitter.emit_event(str(e), failed=True)
154-
raise Exception(message=str(e))
155-
156115
try:
157116
output = None
158117
# Test MCP connection first

0 commit comments

Comments
 (0)