Skip to content
🎉 Launch sale:50% off everything over $22 — automatically applied at checkout· ends Aug 2Shop the sale →
DevOps AI ToolKit
Newsletter
All prompts
AI for Microsoft Teams Difficulty: Advanced ClaudeChatGPT

Teams Bot SSO On-Behalf-Of Downstream Graph Token Exchange Prompt

Implement the On-Behalf-Of flow that exchanges a Teams SSO token for a downstream Microsoft Graph access token inside a bot, including consent fallback

Target user
engineers building Microsoft Teams ChatOps with delegated Graph access
Difficulty
Advanced
Tools
Claude, ChatGPT

The prompt

You are a senior platform engineer who builds Microsoft Teams automation and implements OAuth On-Behalf-Of (OBO) token exchange for Teams SSO bots.

I will provide:
- My Entra app registration details (client ID, exposed API scope `api://.../access_as_user`, the Graph delegated scopes I need)
- My bot runtime (Bot Framework SDK language, where I receive the SSO token from the Teams JS getAuthToken or token exchange invoke)
- The downstream call I want to make (which Graph endpoint and why)

Your job:

1. **Trace the token path** — show how the SSO id/access token arrives at the bot (tokenExchange invoke or TeamsSSO), and confirm it is the bot's own exposed API audience, not a Graph token yet.
2. **Build the OBO request** — produce the exact `/oauth2/v2.0/token` call with `grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer`, `requested_token_use=on_behalf_of`, assertion, and Graph scopes.
3. **Handle consent gaps** — detect the `invalid_grant` / `interaction_required` / suberror `consent_required` response and return the OAuth card / signin flow to collect missing consent.
4. **Cache and refresh** — describe per-user token caching keyed by AAD object ID and how to refresh without re-prompting.
5. **Validate the assertion audience** — verify the incoming token's `aud` and `scp` before exchange so I do not forward a token meant for another resource.
6. **Make the Graph call** — show the downstream call using the exchanged token and how to surface 401/403 distinctly from consent errors.

Output as: a sequence diagram in text, annotated code for the OBO exchange, the consent-fallback branch, and a checklist of Entra app config (scopes, redirect URIs, admin consent).

Do not log raw tokens or assertions; if any scope or endpoint is uncertain, flag it and tell me to verify against current Entra OAuth docs.

Run this prompt with AI

Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.

Related prompts

More Microsoft Teams prompts & error guides

Browse every Microsoft Teams prompt and troubleshooting guide in one place.

Free download · 368-page PDF

Reading prompts? Get all 500 in one free PDF

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.