Skip to content

Commit 4e16293

Browse files
committed
Add E2B_ACCESS_TOKEN support and improve team ID discovery
- Add bearer_hdr() helper for AccessTokenAuth endpoints - Read E2B_ACCESS_TOKEN env var for GET /teams and legacy template endpoints - Discover team ID via GET /teams when Bearer token is available
1 parent 55ebf7a commit 4e16293

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

scripts/validate_api_reference.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,9 +639,25 @@ def cleanup(self):
639639
# TEAM ID DISCOVERY
640640
# ---------------------------------------------------------------------------
641641

642-
def discover_team_id(api_key: str, env_team_id: str | None) -> str | None:
642+
def discover_team_id(api_key: str, env_team_id: str | None,
643+
access_token: str | None = None) -> str | None:
643644
if env_team_id:
644645
return env_team_id
646+
# Try GET /teams with Bearer token first (most reliable source)
647+
if access_token:
648+
status, body, _ = ctrl("GET", "/teams", headers=bearer_hdr(access_token))
649+
if status == 200 and isinstance(body, list):
650+
for team in body:
651+
if team.get("isDefault"):
652+
tid = team.get("teamID")
653+
if tid:
654+
return tid
655+
# Fall back to first team if none is default
656+
for team in body:
657+
tid = team.get("teamID")
658+
if tid:
659+
return tid
660+
# Fall back to templates/sandboxes with API key
645661
h = api_key_hdr(api_key)
646662
status, body, _ = ctrl("GET", "/templates", headers=h)
647663
if status == 200 and isinstance(body, list):
@@ -2265,7 +2281,7 @@ def main():
22652281
print(f" Spec paths: {len(spec.get('paths', {}))}")
22662282

22672283
# Discover team ID
2268-
team_id = discover_team_id(api_key, env_team_id)
2284+
team_id = discover_team_id(api_key, env_team_id, access_token=access_token)
22692285
print(f" Team ID: {team_id[:16]}..." if team_id else " Team ID: (not found)")
22702286

22712287
start_time = time.time()

0 commit comments

Comments
 (0)