feat: Add runtime token exchange, OBO, cross-tenant, and permission granting#195
Open
ArLucaID wants to merge 1 commit into
Open
feat: Add runtime token exchange, OBO, cross-tenant, and permission granting#195ArLucaID wants to merge 1 commit into
ArLucaID wants to merge 1 commit into
Conversation
…ranting Addresses 6 gaps in the entra-agent-id skill: 1. Runtime token exchange — Added fmi_path two-step exchange pattern (parent token via client_credentials + fmi_path, then client_assertion exchange for Graph-scoped Agent Identity token). Covers both autonomous (app-only) and OBO (delegated) modes with complete code samples. 2. fmi_path parameter — Documented the fmi_path parameter on the standard /oauth2/v2.0/token endpoint that targets a specific Agent Identity. Clarified this is NOT RFC 8693 token exchange (which returns AADSTS82001). 3. OBO/delegated flow — Added Blueprint API configuration (identifierUris, oauth2PermissionScopes, preAuthorizedApplications, optionalClaims), user token audience requirements, and complete OBO exchange code. 4. Cross-tenant guidance — Documented that fmi_path works cross-tenant when the Blueprint is multi-tenant. Critical rule: step 1 must target the Agent Identity's home tenant, not the Blueprint's (AADSTS700211 otherwise). 5. Permission granting — Added appRoleAssignments for autonomous mode and oauth2PermissionGrants for OBO mode, with per-agent scoping examples. 6. oauth2-token-flow.md completion — Option B now shows the full two-step exchange (was incomplete — stopped at Blueprint token). Added Option C for OBO flow. Added cross-tenant exchange section. Updated acceptance-criteria.md with sections 9-12 covering runtime exchange, OBO, cross-tenant, and permission grant patterns (correct/incorrect examples). Added Troubleshooting table with 8 common errors and fixes. Tested patterns verified against live Entra endpoints (same-tenant autonomous, cross-tenant fmi_path exchange, OBO with delegated permissions).
Contributor
Author
|
@thegovind / @spboyer : Could I get some help in merging this one? I don't have permissions to request reviewers. |
thegovind
reviewed
May 7, 2026
Collaborator
thegovind
left a comment
There was a problem hiding this comment.
Review summary
Substantial, security-sensitive content. The two-step fmi_path exchange pattern, the AADSTS82001/AADSTS700211/AADSTS50013 failure callouts, and the cross-tenant rule (step 1 against the Agent Identity's home tenant) are all correctly framed. Code samples avoid hardcoded secrets and use parameters cleanly. One real bug to fix and a few recommendations.
Issues
🔴 Blocking
- Regression at
entra-agent-id/SKILL.mdL53. The diff turnsThe hyphen was replaced by a space, which would surface in copy-paste as an invalid-AZURE_TENANT_ID=<your-tenant-id> +AZURE_TENANT_ID=<your tenant-id>.envvalue. Looks like an unintended edit while reformatting; please restore<your-tenant-id>.
🟡 Recommended
- Prefer
msalfor token-acquisition samples (or at least cross-link). The new examples useurllib.requestagainst/oauth2/v2.0/tokendirectly. That's instructive for showing the wire format, but it bypasses MSAL's caching, retry/throttling, PKCE, and proof-of-possession features. Production callers should usemsal.ConfidentialClientApplication(and itsacquire_token_on_behalf_offor OBO). Either:- Add an "msal equivalent" code block alongside the raw
urllibone for the autonomous and OBO exchanges, or - Add a one-line note: "For production use
msal— these raw samples are illustrative of the wire format only".
- Add an "msal equivalent" code block alongside the raw
- Token logging hygiene callout. A skill that walks through three different token shapes (parent token, app-only Graph token, OBO Graph token) is exactly the kind agents may be tempted to log for debugging. Add an explicit "do not log raw tokens, including parent tokens" line in the
## Key Rulessection so the agent doesn't pasteprint(parent_token)into user code. - Audience validation guidance. When the OBO flow returns a delegated Graph token, callers should validate
audandidtyp(the optional claim you correctly added tooptionalClaims). Today the skill teaches acquire; please add a short "Validating the user token at the API" subsection so the Blueprint API resource side of the flow is also covered. scope=.../.defaultrule wording. The "Both exchanges MUST use/.defaultscope" bullet is correct; please tighten the rationale: it's because Entra resolves the consented scope set fromoauth2PermissionGrants/appRoleAssignmentsrather than the request — which is the whole point of per-Agent-Identity scoping. One extra sentence would lock in the why so readers don't second-guess later.AZURE_CLIENT_SECRETin env-var block. The Environment Variables block inSKILL.mdretainsAZURE_CLIENT_SECRET=<app-registration-secret>. Since the Blueprint can also use WIF / federated identity (and the skill teaches this), the env-var snippet should at least mention WIF as the preferred path andclient_secretas the fallback. Avoid teaching beginners that secrets-in-env is the canonical setup.
🟢 Nits
- Worth marking the public preview status of
fmi_pathif it's still preview at GA cut-over. Skills loaded into agent context outlive their preview windows; one explicit version/availability note prevents stale guidance. - Long uuid-generated
scope_id(str(uuid.uuid4())) foroauth2PermissionScopes[].idis correct, but readers may not realize thisidmust be stable across PATCHes (regenerating it breaks existing consents). Add one line. - Acceptance-criteria sections 9–12 — make sure each "incorrect" pattern includes the exact AADSTS code it produces; that's the highest-signal recall hint for a future agent invocation.
Excellent contribution overall — this fills real gaps in the Agent Identity story.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses 6 gaps in the entra-agent-id skill:
Runtime token exchange — Added fmi_path two-step exchange pattern (parent token via client_credentials + fmi_path, then client_assertion exchange for Graph-scoped Agent Identity token). Covers both autonomous (app-only) and OBO (delegated) modes with complete code samples.
fmi_path parameter — Documented the fmi_path parameter on the standard /oauth2/v2.0/token endpoint that targets a specific Agent Identity. Clarified this is NOT RFC 8693 token exchange (which returns AADSTS82001).
OBO/delegated flow — Added Blueprint API configuration (identifierUris, oauth2PermissionScopes, preAuthorizedApplications, optionalClaims), user token audience requirements, and complete OBO exchange code.
Cross-tenant guidance — Documented that fmi_path works cross-tenant when the Blueprint is multi-tenant. Critical rule: step 1 must target the Agent Identity's home tenant, not the Blueprint's (AADSTS700211 otherwise).
Permission granting — Added appRoleAssignments for autonomous mode and oauth2PermissionGrants for OBO mode, with per-agent scoping examples.
oauth2-token-flow.md completion — Option B now shows the full two-step exchange (was incomplete — stopped at Blueprint token). Added Option C for OBO flow. Added cross-tenant exchange section.
Also included
Files changed (3 files, +810 / -14)