scripts/show_permissions.py¶
Purpose¶
Show the delegated oauth2PermissionGrants scoped to the Agent Identity's
service principal and Agent User — a focused, permissions-only view.
Compare against show_agent_status.py, which
includes this same data plus the rest of the Agent Identity chain.
Requirements¶
- Python 3.12+ with
entrabotinstalled. - The Provisioner app must already be bootstrapped with its certificate
private key present in the OS keystore — this command mints its Graph
token the same way
show_agent_status.pydoes (ProvisionerCertificateCredential), not the Agent User three-hop flow. .entrabot-state.jsonmust containAGENT_OBJECT_IDandAGENT_USER_ID.- Works on macOS, Linux, and Windows.
Usage¶
python scripts/show_permissions.py
python scripts/show_permissions.py --json
python scripts/show_permissions.py --help
Options¶
--json— print the grants as a JSON array (each entry hasid,resourceId,scopes,consentType, andresourceNamewhen it could be resolved) instead of the human-readable text block.
No positional arguments.
Effects¶
- Acquires a Provisioner Graph token (read-only).
- Reads
AGENT_OBJECT_IDandAGENT_USER_IDfrom local state. - GETs
/oauth2PermissionGrants?$filter=clientId eq '{agentOid}' and principalId eq '{agentUserId}'. - For each distinct
resourceIdon the returned grants, GETs/servicePrincipals/{resourceId}to resolve a display name — best effort; a failed lookup is silently skipped, not fatal. - Prints either the JSON array, or per grant: the resolved resource name
(or the raw
resourceIdif unresolved), consent type, and space-separated scopes, followed by a total grant count. - No writes to Graph or local state.
Exit behavior¶
- Returns
1if the Provisioner token can't be acquired (ProvisionerBootstrapError; message printed to stdout). - Returns
1ifAGENT_OBJECT_IDorAGENT_USER_IDis missing from state, with a hint to runsetup.shfirst (printed to stdout). - Returns
1if the/oauth2PermissionGrantsGET responds with a non-200 status (status code and body printed to stdout). - Returns
0in every other case, including when zero grants are found (prints "No permission grants found for this Agent Identity."). --helpexits0(argparse default).
Common failures¶
- "Missing AGENT_OBJECT_ID or AGENT_USER_ID in state" — the Agent
Identity / Agent User hasn't been provisioned yet; run
setup.sh(orcreate_entra_agent_ids.py) first. - Non-200 on the grants query — the Provisioner app lacks Graph read
permission for
oauth2PermissionGrants, or the object IDs in state are stale; re-runsetup.shor check the "Permissions" row inshow_agent_status.py. - "No permission grants found" — no consent has been granted for this
Agent Identity yet; see
grant_consent.pyor the consent step insetup.sh.
Related commands¶
show_agent_status.py— the fuller status/health view that includes this same permission data.grant_consent.py— add scopes to the grant this command reads.revoke_consent.py— remove scopes from, or delete, that grant.- Operations scripts index