Azure Auth
by @veeramanikandanr48
Microsoft Entra ID (Azure AD) authentication for React SPAs with MSAL.js and Cloudflare Workers JWT validation using jose library. Full-stack pattern with Authorization Code Flow + PKCE. Prevents 8 documented errors. Use when: implementing Microsoft SSO, troubleshooting AADSTS50058 loops, AADSTS700084 refresh token errors, React Router redirects, setActiveAccount re-render issues, or validating Entra ID tokens in Workers.
1. Install Dependencies
# Frontend (React SPA)
npm install @azure/msal-react @azure/msal-browserBackend (Cloudflare Workers)
npm install jose
2. Azure Portal Setup
1. Go to Microsoft Entra ID β App registrations β New registration
2. Set Redirect URI to http://localhost:5173 (SPA type)
3. Note the Application (client) ID and Directory (tenant) ID
4. Under Authentication:
- Enable Access tokens and ID tokens
- Add production redirect URI
5. Under API permissions:
- Add User.Read (Microsoft Graph)
- Grant admin consent if required
clawhub install azure-auth