[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M74ACY867CDKN3WNHPHMZYQB":3,"skill-same:01M74ACY867CDKN3WNHPHMZYQB":56},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":26,"commitSha":27,"skillDirectory":28,"forksCount":29,"repositoryHtmlUrl":30,"repositoryHomepageUrl":31,"ownerHtmlUrl":32,"ownerBlogUrl":33,"ownerDescription":34,"updatedAt":35,"install":36,"resources":49},"01M74ACY867CDKN3WNHPHMZYQB","browser-bearer-graph-auth",null,"Conditional-Access-resilient OAuth alternative for Microsoft Graph: drive a Playwright + Edge persistent context to capture the bearer token during normal sign-in. Works when Device Code Flow \u002F headless OAuth is blocked by AADSTS53003 (Device state: Unregistered). Outlook Web grants a broader scope set than Teams Web. Hard-won workaround that should NOT be the production answer.","CarlosCaPe\u002Foctorato","CarlosCaPe","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F39838249?v=4","01M72WXX4ZRR8MBH1EP1QND2FQ","dataqbs","01M72WXX5NA7YCKRSJ54GW1GQ8",18,"MIT","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fbrowser-bearer-graph-auth\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: browser-bearer-graph-auth\ndescription: \"Conditional-Access-resilient OAuth alternative for Microsoft Graph: drive a Playwright + Edge persistent context to capture the bearer token during normal sign-in. Works when Device Code Flow \u002F headless OAuth is blocked by AADSTS53003 (Device state: Unregistered). Outlook Web grants a broader scope set than Teams Web. Hard-won workaround that should NOT be the production answer.\"\nmetadata:\n  short-description: \"Browser-bearer Graph auth (Conditional-Access-resilient)\"\n---\n\n# Browser-Bearer Microsoft Graph Auth\n\n## What\n\nA pattern for capturing a Microsoft Graph bearer token by driving a real Edge browser via Playwright, intercepting the token from the first authenticated Graph request, and persisting the Edge session for subsequent silent refresh.\n\nThis is the workaround you reach for **after** Conditional Access has blocked every other OAuth path you tried. It is not the production answer. It is the path that lets a single consultant make progress while waiting for an admin-consented App Registration.\n\n## Why\n\nMany enterprise tenants (especially in healthcare, finance, defense) enforce a Conditional Access policy that requires:\n\n- Compliant or hybrid-joined device, OR\n- Device registered with Intune \u002F Entra ID, OR\n- App protection policy active\n\nOAuth Device Code Flow cannot satisfy any of these — the device authenticating in the browser is not the device presenting the code. Headless OAuth flows fail for the same reason. Empirical results from a real tenant:\n\n| OAuth client | Result |\n|---|---|\n| Microsoft Graph PowerShell (`14d82eec-c10e-4ab5-bd9c-b31da76ffd80`) Device Code | BLOCKED — AADSTS53003 \"Device state: Unregistered\" |\n| Azure CLI (`04b07795-8ddb-461a-bbee-02f9e1bf7b46`) Device Code | BLOCKED — same error, even on VPN |\n| `Connect-MgGraph` WAM broker (sandboxed PowerShell) | FAILED — needs window handle, not available from sandboxed shell |\n| Browser-driven (Playwright + Edge) | WORKS — Edge has WAM, sends device identity claim |\n\nEdge with WAM (Web Account Manager) is the missing piece: it satisfies the device-claim requirement that headless flows cannot. By scripting Edge through Playwright, the user signs in once interactively (with MFA), the session is persisted, and subsequent fetches happen silently.\n\n## When to Use\n\n- Tenant blocks Device Code Flow with AADSTS53003 (verify with at least 2 different first-party clients)\n- WAM broker is unavailable from your shell context\n- You need bearer tokens for Microsoft Graph for personal productivity \u002F prototype work\n- The end goal is to **replace this with an admin-consented Azure AD App Registration**, but you need to make progress now\n\nDo NOT use:\n- For production \u002F team \u002F multi-user services — the bearer is per-user and the approach is policy circumvention\n- For systematically extracting content where the file-level ACL denies access (different problem; see related skills and legal review)\n- When you have admin support — request the App Registration and skip this entirely\n\n## Key Insight: Outlook Web vs Teams Web Scopes\n\nDifferent first-party Microsoft web apps request different default scope sets at sign-in. The IdP grants whatever the requesting app asks for, within consent policy. Driving the same Playwright session through different URLs gets different tokens:\n\n| Driving URL | Captured token characteristics |\n|---|---|\n| `teams.microsoft.com` \u002F `teams.cloud.microsoft` | Narrow scope set; typically lacks `Chat.Read`; ~60 min TTL |\n| `outlook.office.com` (One Outlook Web app `9199bf20-a13f-4107-85dc-02114787ef48`) | Broader scope set: `Chat.Read`, `Chat.ReadWrite`, `OnlineMeetings.Read`, `OnlineMeetingArtifact.Read.All`, `Files.ReadWrite.All`, **`Mail.Read`, `Mail.ReadWrite`**, ~24h TTL |\n\nThe Outlook Web first-party client is the better target for a wider scope envelope. Drive Outlook Web first, then Teams variants as fallback. Public app IDs above are documented Microsoft first-party app IDs.\n\n**Mail scopes come free**: any arm that drives Outlook Web during scope-widening gets `Mail.Read` and `Mail.ReadWrite` in the captured token automatically — no scope request, no consent dialog, no extra navigation step beyond the existing Outlook visit. A `read-outlook-mail.js`-style triage tool can run on top of the same token an existing Teams sync uses, with zero new auth work. Validated on a Conditional-Access-strict tenant (ADH, May 2026) where the same captured token served both Teams sync and Outlook inbox triage from the same `.graph-token.json`.\n\n**Note**: scopes that are NOT in the Outlook Web client (and require an admin-consented App Registration to obtain):\n- `ChannelMessage.Read.All`\n- `OnlineMeetingTranscript.Read.All`\n- `Chat.ReadBasic`\n\nIf your work requires those, no browser-bearer trick will help — escalate to App Registration.\n\n## Workflow\n\n### 1. One-time interactive auth\n\n```bash\nnode \u003Carm>\u002Fauth-via-browser.js login\n```\n\nThe script:\n1. Launches Edge via Playwright with a persistent context dir (`\u003Carm>\u002F.playwright-session-microsoft\u002F`, gitignored)\n2. Navigates to `https:\u002F\u002Foutlook.office.com`\n3. User completes interactive sign-in + MFA in the visible browser\n4. The script intercepts the first authenticated `https:\u002F\u002Fgraph.microsoft.com\u002F...` request\n5. Extracts the bearer from the `Authorization: Bearer ...` header\n6. Saves to `\u003Carm>\u002F.graph-token.json` (gitignored) along with `expires_in`, `_scopes` (decoded from JWT `scp` claim), and capture metadata\n\n### 2. Silent refresh on subsequent runs\n\n```bash\nnode \u003Carm>\u002F\u003Csync-tool>.js\n```\n\nThe orchestrator:\n1. Reads `.graph-token.json`\n2. If still valid, uses it directly\n3. If expired, launches headless Edge with the saved persistent context\n4. Edge auto-completes the OAuth flow using the cached session (no MFA prompt, no UI)\n5. New token captured and saved\n6. Continues with Graph fetches\n\n### 3. Inspect the token (verify scopes)\n\n```bash\n# Extract _scopes array from the saved token file\njq -r '._scopes[]' \u003Carm>\u002F.graph-token.json | sort\n\n# Or decode the JWT scp claim directly\njq -r '.access_token' \u003Carm>\u002F.graph-token.json | \\\n  cut -d. -f2 | base64 -d 2>\u002Fdev\u002Fnull | jq -r '.scp' | tr ' ' '\\n' | sort\n```\n\nThe two should match. If they don't, the `_scopes` array was written from a different capture than the current `access_token`.\n\n## Architecture Skeleton\n\n```\n\u003Carm>\u002F\n├── auth-via-browser.js        ← interactive entry: launches Edge, captures bearer\n├── lib\u002F\n│   ├── graph-helpers.js       ← reads .graph-token.json, exposes graphGet(path) helper\n│   └── teams-scraper.js       ← multi-target navigation (Outlook → Teams variants)\n├── .graph-token.json          ← gitignored\n└── .playwright-session-microsoft\u002F  ← gitignored, Edge persistent context (~90 day cookies)\n```\n\nMulti-target navigation pattern (`lib\u002Fteams-scraper.js`):\n\n```js\nconst TEAMS_SHELL_PATTERNS = [\n  'https:\u002F\u002Foutlook.office.com\u002F...',         \u002F\u002F try Outlook Web first (broader scopes)\n  'https:\u002F\u002Fteams.cloud.microsoft\u002F...',      \u002F\u002F new Teams domain\n  'https:\u002F\u002Fteams.microsoft.com\u002F...',        \u002F\u002F classic Teams\n];\n\u002F\u002F Walk the list; first one that captures a valid token wins.\n```\n\n## Constraints (BE EXPLICIT IN ANY DOC)\n\n- **Policy circumvention**: this approach BYPASSES the Conditional Access policy by satisfying the device-claim requirement through Edge rather than the calling client. Defensible for personal prototype use; NOT defensible for team or production deployment.\n- **Must be replaced**: the production answer is an Azure AD App Registration with admin-consented delegated scopes. File the IT ticket on day 1 of an engagement; this workaround buys you the weeks while it's in flight.\n- **Disclose openly**: in any internal doc or POC presentation, name this auth path explicitly and label it \"EXPERIMENTAL — replace with App Registration before production.\"\n\n## Anti-patterns\n\n| Anti-pattern | Why it fails |\n|---|---|\n| Hardcoding the OAuth client ID of a Microsoft first-party app | The first-party app's scope set is determined by Microsoft, not by you. Treat client IDs as documented constants; rely on app behavior not on requested scopes. |\n| Sharing `.playwright-session-microsoft\u002F` across machines | Sessions are device-bound; sharing breaks the device-identity claim that makes this work in the first place |\n| Committing `.graph-token.json` or the session dir | Both must be gitignored. Never commit. |\n| Using this for scopes that are admin-blocked (`OnlineMeetingTranscript.Read.All`, `ChannelMessage.Read.All`) | No browser dance helps — those need admin-consented App Registration |\n| Hiding this auth path in client-facing docs | Disclose. The hidden risk is the unmanaged risk. |\n| Continuing this past POC into \"production\" | The risk profile changes. App Registration is mandatory by then. |\n| Launching the interactive Edge window with `viewport: { width, height }` + no `--start-maximized` on Windows | Playwright spawns the Edge window without claiming foreground focus; on Windows it lands BEHIND the operator's other windows (especially Cursor\u002FVSCode in full-screen). The operator thinks the script froze, kills it, and the flow fails forever. See \"Windows window-focus gotcha\" below. |\n\n## Windows window-focus gotcha (hard-learned 2026-06-05)\n\n**Symptom**: operator runs the interactive auth flow, the Node process clearly spawned Edge child processes (visible in Task Manager), the persistent-session dir was just written to — but the operator says \"no veo ese edge\" \u002F \"I don't see the window\" and kills the process. Token never refreshes. Reproduces 100% of the time when the operator's primary window is a maximized IDE.\n\n**Root cause**: `chromium.launchPersistentContext(SESSION_DIR, { headless: false, channel: 'msedge', viewport: { width: 1280, height: 900 }, args: ['--disable-blink-features=AutomationControlled'] })` on Windows does TWO things wrong simultaneously:\n\n1. **Fixed `viewport` overrides OS window sizing** — Edge ends up as a small window (~1280×900) that's easy to lose behind a maximized IDE.\n2. **No `--start-maximized` \u002F `--new-window` \u002F `--window-position`** — Playwright doesn't reclaim foreground focus, so the OS opens Edge in z-order behind the active window.\n\nThe combination is silent: no error, no log, the script just waits at `await page.goto(...)` while the user stares at their IDE.\n\n**Fix in the calling Playwright code**:\n\n```js\n\u002F\u002F In the function that launches the persistent context:\nconst visibleArgs = headless\n  ? ['--disable-blink-features=AutomationControlled']\n  : [\n      '--disable-blink-features=AutomationControlled',\n      '--start-maximized',          \u002F\u002F make the window obvious\n      '--window-position=120,80',   \u002F\u002F offset from corner so it isn't hidden by taskbar\n      '--new-window',                \u002F\u002F refuse to merge into an existing Edge process\n    ];\n\nconst context = await chromium.launchPersistentContext(SESSION_DIR, {\n  headless,\n  channel: 'msedge',\n  \u002F\u002F CRITICAL: null viewport in interactive mode — fixed viewport defeats --start-maximized\n  viewport: headless ? { width: 1280, height: 900 } : null,\n  args: visibleArgs,\n});\n\nconst page = context.pages()[0] || await context.newPage();\n\u002F\u002F Pull the window forward BEFORE navigation so user sees it emerge.\nif (!headless) {\n  try { await page.bringToFront(); } catch {}\n}\nawait page.goto(URL, ...);\nif (!headless) {\n  try { await page.bringToFront(); } catch {}  \u002F\u002F again after redirects\n}\n```\n\n**Fix in the operator UX layer** (the launcher script that calls this):\n- Print a **loud, framed warning BEFORE** launching Edge: \"Playwright-spawned Edge can open BEHIND your other windows. ALT+TAB or check taskbar.\"\n- Emit a **heartbeat every 10s** in the wait loop while no URL movement is detected — operator needs to know the script is alive while they hunt for the window.\n- If 30s pass with zero URL change in interactive mode, print an escalation message: \"No URL activity yet — is the Edge window still hidden? ALT+TAB now.\"\n\n**Operator instruction in any RUNBOOK**: explicitly tell the human \"the Edge window may open behind Cursor\u002FVSCode — ALT+TAB before you assume the script froze.\"\n\nThis gotcha cost ~45 minutes of session time before being diagnosed; the brain MUST surface it preemptively whenever a new arm wires up `auth-via-browser.js`-style flows.\n\n## Composability\n\n- `phi-aware-rag-ingestion` — uses the captured token to fetch source content\n- `mcp-stack-setup` (existing) — for the production path, MCP tools authenticate via OAuth flows configured at the MCP-client level (Claude Desktop \u002F Cursor); the browser-bearer pattern is an alternative for non-MCP code\n- `security-threat-model` (existing) — threat model must explicitly cover this auth path's residual risk\n\n## Lessons Learned\n\n- Switching from Teams Web to Outlook Web as the driver URL turned a 60-minute, narrow-scope token into a 24-hour, broad-scope token. Same Playwright code, different first-party client. Significant unblock for almost-zero new code.\n- AADSTS53003 with sub-detail \"Device state: Unregistered\" is the canonical signature of \"Conditional Access wants a device claim you can't provide.\" Stop trying Device Code variants when you see this. Pivot to browser-bearer.\n- Re-running the silent refresh through Outlook Web (not Teams) is critical — when Teams Web silently changes URL during refresh (e.g., to `teams.cloud.microsoft`), the multi-target pattern with Outlook FIRST keeps the broad-scope token.\n- Always verify scopes from the JWT `scp` claim, not from the saved `_scopes` field. Discrepancies between the two indicate you're reading a stale capture.\n- **`Mail.Read`\u002F`Mail.ReadWrite` are bundled into the Outlook-driven token automatically**: an arm that already has the Teams\u002FOutlook auth path running can ship a new inbox-triage feature (see `inbox-triage-classifier`) without filing an admin ticket for new scopes. Validated: same captured token served Teams sync AND Outlook follow-up scanner from a single `.graph-token.json` (ADH, 2026-05-22).\n","# Browser-Bearer Microsoft Graph Auth\n\n## What\n\nA pattern for capturing a Microsoft Graph bearer token by driving a real Edge browser via Playwright, intercepting the token from the first authenticated Graph request, and persisting the Edge session for subsequent silent refresh.\n\nThis is the workaround you reach for **after** Conditional Access has blocked every other OAuth path you tried. It is not the production answer. It is the path that lets a single consultant make progress while waiting for an admin-consented App Registration.\n\n## Why\n\nMany enterprise tenants (especially in healthcare, finance, defense) enforce a Conditional Access policy that requires:\n\n- Compliant or hybrid-joined device, OR\n- Device registered with Intune \u002F Entra ID, OR\n- App protection policy active\n\nOAuth Device Code Flow cannot satisfy any of these — the device authenticating in the browser is not the device presenting the code. Headless OAuth flows fail for the same reason. Empirical results from a real tenant:\n\n| OAuth client | Result |\n|---|---|\n| Microsoft Graph PowerShell (`14d82eec-c10e-4ab5-bd9c-b31da76ffd80`) Device Code | BLOCKED — AADSTS53003 \"Device state: Unregistered\" |\n| Azure CLI (`04b07795-8ddb-461a-bbee-02f9e1bf7b46`) Device Code | BLOCKED — same error, even on VPN |\n| `Connect-MgGraph` WAM broker (sandboxed PowerShell) | FAILED — needs window handle, not available from sandboxed shell |\n| Browser-driven (Playwright + Edge) | WORKS — Edge has WAM, sends device identity claim |\n\nEdge with WAM (Web Account Manager) is the missing piece: it satisfies the device-claim requirement that headless flows cannot. By scripting Edge through Playwright, the user signs in once interactively (with MFA), the session is persisted, and subsequent fetches happen silently.\n\n## When to Use\n\n- Tenant blocks Device Code Flow with AADSTS53003 (verify with at least 2 different first-party clients)\n- WAM broker is unavailable from your shell context\n- You need bearer tokens for Microsoft Graph for personal productivity \u002F prototype work\n- The end goal is to **replace this with an admin-consented Azure AD App Registration**, but you need to make progress now\n\nDo NOT use:\n- For production \u002F team \u002F multi-user services — the bearer is per-user and the approach is policy circumvention\n- For systematically extracting content where the file-level ACL denies access (different problem; see related skills and legal review)\n- When you have admin support — request the App Registration and skip this entirely\n\n## Key Insight: Outlook Web vs Teams Web Scopes\n\nDifferent first-party Microsoft web apps request different default scope sets at sign-in. The IdP grants whatever the requesting app asks for, within consent policy. Driving the same Playwright session through different URLs gets different tokens:\n\n| Driving URL | Captured token characteristics |\n|---|---|\n| `teams.microsoft.com` \u002F `teams.cloud.microsoft` | Narrow scope set; typically lacks `Chat.Read`; ~60 min TTL |\n| `outlook.office.com` (One Outlook Web app `9199bf20-a13f-4107-85dc-02114787ef48`) | Broader scope set: `Chat.Read`, `Chat.ReadWrite`, `OnlineMeetings.Read`, `OnlineMeetingArtifact.Read.All`, `Files.ReadWrite.All`, **`Mail.Read`, `Mail.ReadWrite`**, ~24h TTL |\n\nThe Outlook Web first-party client is the better target for a wider scope envelope. Drive Outlook Web first, then Teams variants as fallback. Public app IDs above are documented Microsoft first-party app IDs.\n\n**Mail scopes come free**: any arm that drives Outlook Web during scope-widening gets `Mail.Read` and `Mail.ReadWrite` in the captured token automatically — no scope request, no consent dialog, no extra navigation step beyond the existing Outlook visit. A `read-outlook-mail.js`-style triage tool can run on top of the same token an existing Teams sync uses, with zero new auth work. Validated on a Conditional-Access-strict tenant (ADH, May 2026) where the same captured token served both Teams sync and Outlook inbox triage from the same `.graph-token.json`.\n\n**Note**: scopes that are NOT in the Outlook Web client (and require an admin-consented App Registration to obtain):\n- `ChannelMessage.Read.All`\n- `OnlineMeetingTranscript.Read.All`\n- `Chat.ReadBasic`\n\nIf your work requires those, no browser-bearer trick will help — escalate to App Registration.\n\n## Workflow\n\n### 1. One-time interactive auth\n\n```bash\nnode \u003Carm>\u002Fauth-via-browser.js login\n```\n\nThe script:\n1. Launches Edge via Playwright with a persistent context dir (`\u003Carm>\u002F.playwright-session-microsoft\u002F`, gitignored)\n2. Navigates to `https:\u002F\u002Foutlook.office.com`\n3. User completes interactive sign-in + MFA in the visible browser\n4. The script intercepts the first authenticated `https:\u002F\u002Fgraph.microsoft.com\u002F...` request\n5. Extracts the bearer from the `Authorization: Bearer ...` header\n6. Saves to `\u003Carm>\u002F.graph-token.json` (gitignored) along with `expires_in`, `_scopes` (decoded from JWT `scp` claim), and capture metadata\n\n### 2. Silent refresh on subsequent runs\n\n```bash\nnode \u003Carm>\u002F\u003Csync-tool>.js\n```\n\nThe orchestrator:\n1. Reads `.graph-token.json`\n2. If still valid, uses it directly\n3. If expired, launches headless Edge with the saved persistent context\n4. Edge auto-completes the OAuth flow using the cached session (no MFA prompt, no UI)\n5. New token captured and saved\n6. Continues with Graph fetches\n\n### 3. Inspect the token (verify scopes)\n\n```bash\n# Extract _scopes array from the saved token file\njq -r '._scopes[]' \u003Carm>\u002F.graph-token.json | sort\n\n# Or decode the JWT scp claim directly\njq -r '.access_token' \u003Carm>\u002F.graph-token.json | \\\n  cut -d. -f2 | base64 -d 2>\u002Fdev\u002Fnull | jq -r '.scp' | tr ' ' '\\n' | sort\n```\n\nThe two should match. If they don't, the `_scopes` array was written from a different capture than the current `access_token`.\n\n## Architecture Skeleton\n\n```\n\u003Carm>\u002F\n├── auth-via-browser.js        ← interactive entry: launches Edge, captures bearer\n├── lib\u002F\n│   ├── graph-helpers.js       ← reads .graph-token.json, exposes graphGet(path) helper\n│   └── teams-scraper.js       ← multi-target navigation (Outlook → Teams variants)\n├── .graph-token.json          ← gitignored\n└── .playwright-session-microsoft\u002F  ← gitignored, Edge persistent context (~90 day cookies)\n```\n\nMulti-target navigation pattern (`lib\u002Fteams-scraper.js`):\n\n```js\nconst TEAMS_SHELL_PATTERNS = [\n  'https:\u002F\u002Foutlook.office.com\u002F...',         \u002F\u002F try Outlook Web first (broader scopes)\n  'https:\u002F\u002Fteams.cloud.microsoft\u002F...',      \u002F\u002F new Teams domain\n  'https:\u002F\u002Fteams.microsoft.com\u002F...',        \u002F\u002F classic Teams\n];\n\u002F\u002F Walk the list; first one that captures a valid token wins.\n```\n\n## Constraints (BE EXPLICIT IN ANY DOC)\n\n- **Policy circumvention**: this approach BYPASSES the Conditional Access policy by satisfying the device-claim requirement through Edge rather than the calling client. Defensible for personal prototype use; NOT defensible for team or production deployment.\n- **Must be replaced**: the production answer is an Azure AD App Registration with admin-consented delegated scopes. File the IT ticket on day 1 of an engagement; this workaround buys you the weeks while it's in flight.\n- **Disclose openly**: in any internal doc or POC presentation, name this auth path explicitly and label it \"EXPERIMENTAL — replace with App Registration before production.\"\n\n## Anti-patterns\n\n| Anti-pattern | Why it fails |\n|---|---|\n| Hardcoding the OAuth client ID of a Microsoft first-party app | The first-party app's scope set is determined by Microsoft, not by you. Treat client IDs as documented constants; rely on app behavior not on requested scopes. |\n| Sharing `.playwright-session-microsoft\u002F` across machines | Sessions are device-bound; sharing breaks the device-identity claim that makes this work in the first place |\n| Committing `.graph-token.json` or the session dir | Both must be gitignored. Never commit. |\n| Using this for scopes that are admin-blocked (`OnlineMeetingTranscript.Read.All`, `ChannelMessage.Read.All`) | No browser dance helps — those need admin-consented App Registration |\n| Hiding this auth path in client-facing docs | Disclose. The hidden risk is the unmanaged risk. |\n| Continuing this past POC into \"production\" | The risk profile changes. App Registration is mandatory by then. |\n| Launching the interactive Edge window with `viewport: { width, height }` + no `--start-maximized` on Windows | Playwright spawns the Edge window without claiming foreground focus; on Windows it lands BEHIND the operator's other windows (especially Cursor\u002FVSCode in full-screen). The operator thinks the script froze, kills it, and the flow fails forever. See \"Windows window-focus gotcha\" below. |\n\n## Windows window-focus gotcha (hard-learned 2026-06-05)\n\n**Symptom**: operator runs the interactive auth flow, the Node process clearly spawned Edge child processes (visible in Task Manager), the persistent-session dir was just written to — but the operator says \"no veo ese edge\" \u002F \"I don't see the window\" and kills the process. Token never refreshes. Reproduces 100% of the time when the operator's primary window is a maximized IDE.\n\n**Root cause**: `chromium.launchPersistentContext(SESSION_DIR, { headless: false, channel: 'msedge', viewport: { width: 1280, height: 900 }, args: ['--disable-blink-features=AutomationControlled'] })` on Windows does TWO things wrong simultaneously:\n\n1. **Fixed `viewport` overrides OS window sizing** — Edge ends up as a small window (~1280×900) that's easy to lose behind a maximized IDE.\n2. **No `--start-maximized` \u002F `--new-window` \u002F `--window-position`** — Playwright doesn't reclaim foreground focus, so the OS opens Edge in z-order behind the active window.\n\nThe combination is silent: no error, no log, the script just waits at `await page.goto(...)` while the user stares at their IDE.\n\n**Fix in the calling Playwright code**:\n\n```js\n\u002F\u002F In the function that launches the persistent context:\nconst visibleArgs = headless\n  ? ['--disable-blink-features=AutomationControlled']\n  : [\n      '--disable-blink-features=AutomationControlled',\n      '--start-maximized',          \u002F\u002F make the window obvious\n      '--window-position=120,80',   \u002F\u002F offset from corner so it isn't hidden by taskbar\n      '--new-window',                \u002F\u002F refuse to merge into an existing Edge process\n    ];\n\nconst context = await chromium.launchPersistentContext(SESSION_DIR, {\n  headless,\n  channel: 'msedge',\n  \u002F\u002F CRITICAL: null viewport in interactive mode — fixed viewport defeats --start-maximized\n  viewport: headless ? { width: 1280, height: 900 } : null,\n  args: visibleArgs,\n});\n\nconst page = context.pages()[0] || await context.newPage();\n\u002F\u002F Pull the window forward BEFORE navigation so user sees it emerge.\nif (!headless) {\n  try { await page.bringToFront(); } catch {}\n}\nawait page.goto(URL, ...);\nif (!headless) {\n  try { await page.bringToFront(); } catch {}  \u002F\u002F again after redirects\n}\n```\n\n**Fix in the operator UX layer** (the launcher script that calls this):\n- Print a **loud, framed warning BEFORE** launching Edge: \"Playwright-spawned Edge can open BEHIND your other windows. ALT+TAB or check taskbar.\"\n- Emit a **heartbeat every 10s** in the wait loop while no URL movement is detected — operator needs to know the script is alive while they hunt for the window.\n- If 30s pass with zero URL change in interactive mode, print an escalation message: \"No URL activity yet — is the Edge window still hidden? ALT+TAB now.\"\n\n**Operator instruction in any RUNBOOK**: explicitly tell the human \"the Edge window may open behind Cursor\u002FVSCode — ALT+TAB before you assume the script froze.\"\n\nThis gotcha cost ~45 minutes of session time before being diagnosed; the brain MUST surface it preemptively whenever a new arm wires up `auth-via-browser.js`-style flows.\n\n## Composability\n\n- `phi-aware-rag-ingestion` — uses the captured token to fetch source content\n- `mcp-stack-setup` (existing) — for the production path, MCP tools authenticate via OAuth flows configured at the MCP-client level (Claude Desktop \u002F Cursor); the browser-bearer pattern is an alternative for non-MCP code\n- `security-threat-model` (existing) — threat model must explicitly cover this auth path's residual risk\n\n## Lessons Learned\n\n- Switching from Teams Web to Outlook Web as the driver URL turned a 60-minute, narrow-scope token into a 24-hour, broad-scope token. Same Playwright code, different first-party client. Significant unblock for almost-zero new code.\n- AADSTS53003 with sub-detail \"Device state: Unregistered\" is the canonical signature of \"Conditional Access wants a device claim you can't provide.\" Stop trying Device Code variants when you see this. Pivot to browser-bearer.\n- Re-running the silent refresh through Outlook Web (not Teams) is critical — when Teams Web silently changes URL during refresh (e.g., to `teams.cloud.microsoft`), the multi-target pattern with Outlook FIRST keeps the broad-scope token.\n- Always verify scopes from the JWT `scp` claim, not from the saved `_scopes` field. Discrepancies between the two indicate you're reading a stale capture.\n- **`Mail.Read`\u002F`Mail.ReadWrite` are bundled into the Outlook-driven token automatically**: an arm that already has the Teams\u002FOutlook auth path running can ship a new inbox-triage feature (see `inbox-triage-classifier`) without filing an admin ticket for new scopes. Validated: same captured token served Teams sync AND Outlook follow-up scanner from a single `.graph-token.json` (ADH, 2026-05-22).\n",{"name":5,"metadata":24,"description":7},{"short-description":25},"Browser-bearer Graph auth (Conditional-Access-resilient)","master","b4414608cd5a3f87d1525b518f1c6add8363540d","skills\u002Fbrowser-bearer-graph-auth",6,"https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato","https:\u002F\u002Fwww.dataqbs.com\u002Foctorato","https:\u002F\u002Fgithub.com\u002FCarlosCaPe","www.dataqbs.com"," AI-powered data engineering\r\n& consulting\r\n\r\nWe build data platforms that turn complexity into clarity — from cloud architecture and ETL pipelines to AI-driven","2026-11-14 00:21:00",{"source":8,"skillName":5,"commands":37,"prompt":47,"zipAvailable":48},[38,41,44],{"tool":39,"command":40},"npx","npx skills add CarlosCaPe\u002Foctorato --skill browser-bearer-graph-auth",{"tool":42,"command":43},"bunx","bunx skills add CarlosCaPe\u002Foctorato --skill browser-bearer-graph-auth",{"tool":45,"command":46},"pnpm","pnpm dlx skills add CarlosCaPe\u002Foctorato --skill browser-bearer-graph-auth","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fbrowser-bearer-graph-auth\u002FSKILL.md",true,[50],{"path":51,"resourceType":52,"resourceTypeDesc":53,"sizeBytes":54,"sourceHtmlUrl":55},"skill.json","REFERENCE","参考文档",505,"https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fbrowser-bearer-graph-auth\u002Fskill.json",[57,66,74,81,89,97],{"skillNo":58,"name":59,"nameZh":6,"description":60,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":61,"licenseFileUrl":62,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M74EVAA4A4B4AKR5TT732GP4","yeet","Use only when the user explicitly asks to stage, commit, push, and open a GitHub pull request in one flow using the GitHub CLI (`gh`).","Apache-2.0","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fyeet\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fyeet\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":61,"licenseFileUrl":70,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":19},"01M74EV4WMRDKP2NQS4YWR8PXH","wrangler","Cloudflare Workers CLI for deploying, developing, and managing Workers, KV, R2, D1, Vectorize, Hyperdrive, Workers AI, Containers, Queues, Workflows, Pipelines, and Secrets Store. Load before running wrangler commands to ensure correct syntax and best practices. Biases towards retrieval from Cloudflare docs over pre-trained knowledge.","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fwrangler\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fwrangler\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":19},"01M74EV05MHTXKEXD4B2QJEYTF","workspace-skill-discovery","Discover and include ALL skills across the workspace — not just global ones. Use at the start of every session or when the user asks about available skills. Ensures project-level skills (under .claude\u002Fskills\u002F or skills\u002F in any repo) are never missed.","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fworkspace-skill-discovery\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":61,"licenseFileUrl":85,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":19},"01M74ETV78525B4VP2F28Z6NRD","workers-best-practices","Reviews and authors Cloudflare Workers code against production best practices. Load when writing new Workers, reviewing Worker code, configuring wrangler.jsonc, or checking for common Workers anti-patterns (streaming, floating promises, global state, secrets, bindings, observability). Biases towards retrieval from Cloudflare docs over pre-trained knowledge.","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fworkers-best-practices\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fworkers-best-practices\u002FSKILL.md",[],[],{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":61,"licenseFileUrl":93,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":19},"01M74ETR75NF67WGVEN7288ACV","winui-app","Create, build and design WinUI 3 desktop apps with C# and the Windows App SDK following Microsoft's official guidance and CommunityToolkit. Covers XAML, navigation, theming, accessibility and deployment.","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fwinui-app\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fwinui-app\u002FSKILL.md",[],[],{"skillNo":98,"name":99,"nameZh":6,"description":100,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":101,"categories":102,"keywords":103,"publishedAt":19},"01M74ETJFRNPPNSQZ36C6HD6CW","windows-brain-script-portability","Scripts in ~\u002F.claude\u002Fscripts\u002F that run on a Windows brain: use the python3.cmd shim and not bare python3, and reconfigure stdout to UTF-8 if you print symbols. Use it when writing a brain script or triaging a Windows-only crash.","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fwindows-brain-script-portability\u002FSKILL.md",[],[]]