Client events and isolation
Client behavior is not authorization
The Power BI JavaScript client embeds an authorized report and exposes events and operations. Use the loaded event for APIs that require an initialized report, rendered for presentation completion, and error for handling failures. A filter changes the report view within permitted rows; RLS and source access are the authority. Client-side filter removal, hidden panes, or disabled buttons cannot replace server/model security.
SDK integration shape
Illustrative SDK excerpt, not executable in this offline package: assume a trusted backend already supplied authorized and the real Power BI SDK, models and DOM container are initialized. Do not log authorized.accessToken.
const report = powerbi.embed(container, { type: "report", id: authorized.reportId, embedUrl: authorized.embedUrl, accessToken: authorized.accessToken, tokenType: models.TokenType.Embed});report.on("loaded", () => showControls());report.on("rendered", () => showReady());report.on("error", () => showSafeError());Use report.off for registered event handlers and powerbi.reset(container) during teardown. For a supported report, await report.updateFilters(models.FiltersOperations.RemoveAll) removes report-level filters, not RLS, page or visual filters. Check SDK version and API support for the item type.
Worked example 1 — filter and isolation
Run the supplied mock using Node. Alice’s authorized North rows are worth $150. Setting the report filter to South yields zero in the mock (an empty row set); clearing it restores $150, never A South or B North. A report request for sales-b is denied before token issuance. The zero here is a teaching aggregate convention; native DAX measures may return BLANK for no rows. Inspect row IDs, not only totals.
Worked example 2 — renewal and failure state
In the mock, load at second 0, render at 1, call tick at 49 (no renewal) and 50 (renewal). After revoking Alice, tick at 100 blocks further UI rendering. Without renewal, rendering at second 60 fails. In a real app-owns-data integration, obtain a fresh embed token from the backend and call await report.setAccessToken(newToken). Organization embedding can also use eventHooks.accessTokenProvider for automatic Entra-token renewal on powerbi-client 2.20.1 or later; that hook should return null on failure. Do not use it as an automatic customer-embed token renewal mechanism.
Operational safeguards
In a real asynchronous application, serialize renewal or guard responses with session generation IDs; discard results from an old customer session after a switch. Clear timers and event handlers on unmount, protect logs and prevent stale content after denied renewal. Recheck on tab visibility changes and honor actual expiration timestamps. Test actual embed tokens and denied exports in an approved sandbox, including direct model/source access. Mock event order and expiry are not SDK evidence.
Practice and references
Run node verify.mjs in the lab directory. Add a wrong-report test and explain why removing filters cannot widen the row set. Check client events, filter operations and token renewal. Next: Copilot and responsible use.