| Use authorization code + PKCE for browser apps |
SPAs are public clients and cannot safely hold a client secret. |
Request API scopes such as api://{api-client-id}/Evidence.Read from the SPA. |
| Request least-privilege scopes |
Scopes are the user's delegated permissions to an API. |
Expose narrow scopes on the API app registration instead of broad, reusable catch-all scopes. |
| Prefer silent token acquisition where applicable |
MSAL maintains token caches and can refresh tokens before expiry. |
In browser and confidential-client apps, attempt silent acquisition before interactive prompts when the flow supports it. |
| Handle Conditional Access claim challenges |
MFA, device compliance, and other policies can require extra claims before a token is issued. |
Catch token acquisition exceptions and route the user through the challenge rather than failing with a generic error. |
| Enable diagnostics without logging secrets |
Authentication failures often require correlation IDs and authority details. |
Keep PII logging disabled in normal environments and log correlation IDs, tenant, authority, and error codes. |
| Use tenant-specific authorities when possible |
A tenant authority reduces ambiguity and aligns issuer validation with the API. |
Use https://login.microsoftonline.com/{tenant-id} unless the app is intentionally multi-tenant. |