M365Con 2027 – free online conference · 11–22 Jan 2027 · 120 sessions→ m365con.net

2025-08-05

Fix Multi-Tenant SPFx Authentication

Fix Multi-Tenant SPFx Authentication
Shipping a SharePoint Framework app to another tenant and watching auth blow up, Graph return nothing, and users not even see the web part? You’re not cursed—multi-tenant SPFx is. In this episode, I show the exact authentication traps that tank cross-tenant deployments, why Graph goes “empty,” and…

Moving an SPFx app from your dev tenant to a client tenant often breaks—silently. In this episode, we unpack why multi-tenant is “hard mode” (identity boundaries, consent, and unpredictable site architectures), then walk through what actually fixes it: converting to a multi-tenant Entra ID app, building a clear admin-consent flow, making config tenant-aware and secret-free, validating Graph access per tenant, and running a single, repeatable packaging/deployment pipeline with monitoring.

Who This Is For

  • SPFx developers and Microsoft 365 consultants shipping to multiple tenants

  • IT admins and MSPs supporting client SharePoint Online environments

  • Partners and ISVs productizing SPFx web parts/extensions

Key Takeaways

  • Auth is not boilerplate: Use a multi-tenant Entra ID app and require per-tenant admin consent; verify at runtime.

  • Never hardcode tenant details: Load URLs, IDs, and scopes from tenant-aware config; store secrets in Key Vault.

  • Graph “empties” ≠ broken code: They’re almost always missing consent or mismatched directory data/filters.

  • One package, many tenants: Design tenant-agnostic SPFx + tenant-scoped deployment to avoid custom builds.

  • See failures early: Centralize telemetry and health checks (Application Insights/Azure Monitor) per tenant.

Highlights

  • The three auth mistakes that tank cross-tenant rollouts (single-tenant app reg, one-time consent myth, secrets-in-code).

  • Why MS Graph works in your tenant and returns nothing in a client’s—and how to prove it before go-live.

  • Packaging once, configuring everywhere: the blueprint for tenant-agnostic SPFx.

  • Logging and monitoring that catch issues before clients do.

  • Governance that keeps you compliant while moving fast.

Quickstart Checklist (Copy/Paste)

  1. Entra ID App Registration

    • Set Supported account types: Multitenant.

    • Define delegated Graph scopes needed (least privilege).

    • Configure redirect URIs for SharePoint Online + localhost dev.

  2. SPFx Project Hardening

    • Use MSGraphClient/AadHttpClient for delegated calls.

    • Read tenant config (endpoints, site IDs) from a config list or secure API; no secrets in code.

    • Add runtime permission checks → show an “Admin consent required” banner with a deep link.

  3. Consent Flow

    • Provide a tenant onboarding page with: required scopes, exact consent URL, and verification steps.

    • Support per-audience consent (entire org vs. pilot group).

  4. Packaging & Deployment

    • Package once (.sppkg), enable tenant-scoped deployment if appropriate.

    • Publish via central App Catalog; document site-level add steps.

    • Automate with a CI pipeline (build → bundle → package → upload → deploy).

  5. Monitoring & Support

    • Emit telemetry (tenant ID, correlation ID, feature, error).

    • Wire Application Insights/Azure Monitor dashboards + alerts.

    • Document a rollback (previous package) and a version map per tenant.

Common Pitfalls (and Fixes)

  • Symptom: Login loops or “works for me, not for them.”
    Cause: App is single-tenant or reply URL mismatch.
    Fix: Switch app reg to multi-tenant, correct redirect URIs, re-consent.

  • Symptom: Graph returns empty sets.
    Cause: Missing tenant admin consent or overly strict filters.
    Fix: Trigger consent flow; test queries in Graph Explorer with a real tenant user; relax assumptions/filters.

  • Symptom: Users can’t add the web part.
    Cause: Not deployed to tenant or app policies block it.
    Fix: Verify App Catalog deployment + tenant app settings/policies.

  • Symptom: Per-tenant rebuilds for small config changes.
    Cause: Hardcoded IDs/URLs/secrets.
    Fix: Externalize config; use Key Vault / config lists; read at runtime.

Governance & Security Essentials

  • Least privilege scopes and regular scope reviews.

  • Store secrets in Azure Key Vault; rotate regularly.

  • Use Teams/SharePoint app permission policies to restrict audiences.

  • Maintain a consent ledger (who consented, when, scopes).

  • Align branding via theme APIs; avoid packing tenant-specific assets.

Validation Plan (Before Client Go-Live)

  • Test Graph calls in client tenant with Graph Explorer (same scopes/account).

  • Run a pilot on one site collection with targeted users.

  • Verify version history & rollback in the App Catalog.

  • Exercise offline/expired token scenarios; confirm your error messaging and recoveries.

FAQs

Do I need application permissions for SPFx?
Usually no. SPFx runs with delegated user context. App perms require extra approvals and special patterns—use only when necessary.

Can I avoid per-tenant consent?
No. Each tenant’s admin must grant your app’s scopes. Streamline it with a guided onboarding and runtime banners.

How do I keep one codebase for many clients?
Make the solution tenant-agnostic, externalize config, and automate packaging/deployment. Use feature flags for client-specific toggles.

How do I diagnose “it’s empty” faster?
Log Graph responses + scope checks; surface an inline “Missing consent / insufficient scope” notice with the exact fix link.

YouTube

Host: Mirko Peters

Related articles

← How Microsoft 365 Office Co-Authoring WorksAutomate Microsoft 365 Tenant Cleanup with PowerShell →