Created
December 19, 2025 00:44
-
-
Save kozmer/14a293a8f1c554d6778f29a7196527da to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import sys | |
| import requests | |
| tenant = ( | |
| sys.argv[1] | |
| if len(sys.argv) > 1 | |
| else sys.exit(f"usage: {sys.argv[0]} <tenant_id or domain>") | |
| ) | |
| try: | |
| url = f"https://accounts.accesscontrol.windows.net/{tenant}/metadata/json/1" | |
| metadata = requests.get(url, timeout=30).json() | |
| realm = metadata.get("realm", tenant) | |
| if tenant != realm: | |
| print(f"tenant: {realm}\n") | |
| domains = set() | |
| for entry in metadata.get("allowedAudiences", []): | |
| domain = entry.split("@")[-1] | |
| if "." in domain: | |
| domains.add(domain) | |
| for domain in domains: | |
| print(domain) | |
| except Exception as e: | |
| sys.exit(f"error: {e}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment