A simple web application for testing Azure AD authentication with MSAL. This app allows you to sign in with Azure AD and test authenticated requests to the backend service.
You can run this application directly without cloning the repository:
npx github:cressie176/azure-ad-jwt-debugger-webNote: You still need to create a .env.local file with your Azure AD configuration before running (see Configuration section below).
- Node.js 18 or higher
- An Azure AD application registration
- The backend service running at
../azure-ad-jwt-debugger
Whether using npx or local development, you must configure your environment variables.
Create a .env.local file in the project directory:
# .env.local
VITE_AZURE_TENANT_ID=your-tenant-id
VITE_AZURE_CLIENT_ID=your-client-id
VITE_API_URL=http://localhost:3002/api/debug/tokenIn the Azure Portal, configure your app registration:
- Go to Azure Portal > Azure Active Directory > App registrations
- Select your application
- Under "Authentication":
- Add a Single-page application (SPA) platform
- Set Redirect URI to
http://localhost:5173(Vite's default port) - Enable "Access tokens" and "ID tokens" under Implicit grant
- Under "API permissions":
- Add delegated permissions for your API
- Under "Expose an API":
- Add a scope called
access_as_user - Note the Application ID URI (format:
api://{client-id})
- Add a scope called
The backend service must be running for API calls to work:
cd ../azure-ad-jwt-debugger
npm install
npm startnpx azure-ad-jwt-debugger-webThe script will:
- Check for
.env.localconfiguration - Install dependencies if needed
- Start the Vite dev server
- Open the application at
http://localhost:5173
If you've cloned the repository:
# Install dependencies
npm install
# Start development server
npm run devThe application will be available at http://localhost:5173
- Click "Sign In" to authenticate with Azure AD
- After signing in, your user information will be displayed
- Click "Call Backend Service" to make an authenticated request to the backend
- The response from the backend service will be displayed, showing your decoded JWT token information
- Azure AD authentication using MSAL.js
- Popup-based sign-in flow
- Automatic token acquisition and refresh
- Bearer token authentication for API calls
- User information display
- API response visualization
- Error handling and display
npm run dev # Start development server with hot reload
npm run build # Build for production
npm run preview # Preview production build- Vite - Build tool and dev server
- MSAL.js - Microsoft Authentication Library for JavaScript
- Vanilla JavaScript - No framework dependencies
- ES Modules - Modern JavaScript modules
- Ensure the redirect URI in Azure AD matches your local development URL
- Check that SPA platform is configured, not Web platform
- Verify the scope format:
api://{client-id}/access_as_user - Ensure API permissions are granted in Azure AD
- Confirm the backend service is running
- Check that
VITE_API_URLpoints to the correct backend endpoint - Verify the backend is configured with the same tenant and client IDs
MIT