Documentation Index
Fetch the complete documentation index at: https://auth0-quickstart-flutter-windows.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites:
- Flutter SDK 3.24.0+ and Dart 3.5.0+
- Windows 10 or newer
- Visual Studio 2022 with Desktop development with C++ workload
- Auth0 account — sign up free
auth0_flutter 2.1.0-beta.1). The API may change before general availability.auth0_flutter SDK with OAuth 2.0 Authorization Code Flow + PKCE.
Get Started
Create a Flutter Windows project
Create a new Flutter project with Windows platform support.Verify Windows is available:You should see a Windows desktop device listed.
Install the Auth0 Flutter SDK
Add the beta version of the SDK that includes Windows support:Your
pubspec.yaml should include:Configure Auth0
Create or configure an Auth0 application with the callback URLs required for Windows desktop authentication.
- Quick Setup
- CLI
- Dashboard
Create a Native application in your Auth0 Dashboard with the following settings:
Your credentials:
| Field | Value |
|---|---|
| Allowed Callback URLs | auth0flutter://callback |
| Allowed Logout URLs | auth0flutter://callback |
- Domain:
{yourDomain} - Client ID:
{yourClientId}
The
auth0flutter://callback URL is a custom scheme that routes the browser callback back to your desktop application after authentication completes.Configure environment variables
Create a
.env file in the root of your project:Add the .env file to your Flutter assets in pubspec.yaml:Configure the Windows runner
The Windows authentication flow requires callback plumbing in your app’s runner. The Flutter plugin does not automatically receive protocol-scheme activations from the OS — you must add single-instance enforcement and URI forwarding.Replace the contents of
windows/runner/main.cpp:This code:- Enforces single-instance via a Windows mutex
- Captures
auth0flutter://callbackURIs passed as command-line arguments - Forwards URIs from secondary launches to the running instance via a named pipe
- Sets the
PLUGIN_STARTUP_URLenvironment variable for the Auth0 plugin to read
Register the custom URL scheme
Register Double-click the Verify the scheme works:Open Command Prompt and run:Your app should launch (or come to the foreground if already running).
auth0flutter as a custom URL scheme so Windows routes callback URIs to your app.Create a file windows/url_scheme.reg:Replace C:\path\to\your\app.exe with the actual path to your built executable. During development this is typically:.reg file to import it into the Windows Registry.For production distribution, register the custom URL scheme programmatically in your app’s installer (MSIX, Inno Setup, etc.) rather than relying on a
.reg file.Implement login and logout
Create
lib/auth_service.dart to handle Windows authentication:The Auth0 Flutter Windows SDK does not currently support credential management. You must manually store credentials if you need sessions to persist across app restarts.
Run your application
Build and run the app:Expected flow:
- App launches with a Log In button
- Click Log In → your system browser opens the Auth0 Universal Login page
- Complete authentication in the browser
- Browser redirects to
auth0flutter://callback→ your app comes to the foreground - User’s name, email, and profile picture are displayed
CheckpointYou should now have a fully functional Auth0 login experience in your Flutter Windows application. The app opens the system browser for Auth0 Universal Login, receives the callback via the custom URL scheme, and displays the authenticated user’s profile.
Troubleshooting & Advanced Usage
Common Issues & Solutions
Common Issues & Solutions
Browser opens but app doesn’t receive callback
Symptom: Auth0 login succeeds in browser but the app never receives the credentials.Fix:- Open Registry Editor →
HKEY_CURRENT_USER\Software\Classes\auth0flutter\shell\open\commandand confirm the path to your.exe - Test with
start auth0flutter://testin Command Prompt — your app should launch - Ensure
windows/runner/main.cppincludes the pipe server and mutex code - Check that no stale instances are running in Task Manager
- Rebuild completely:
flutter clean && flutter run -d windows
Authentication times out after 5 minutes
Symptom: Login appears to hang and eventually fails.Fix: The app never received the callback URI. Verify:- The registry entry points to the correct executable path
- The mutex name
auth0flutter_single_instance_mutexis consistent inmain.cpp - No firewall or antivirus is blocking the named pipe
- Kill all stale instances and rebuild
Second app instance launches instead of forwarding URI
Symptom: A new window opens instead of the existing app receiving the callback.Fix:- Kill all running instances in Task Manager
- Ensure the mutex name is consistent in
main.cpp - Rebuild:
flutter clean && flutter run -d windows
WindowsWebAuthentication not found
Symptom: Compilation error referencingwindowsWebAuthentication.Fix: Ensure your pubspec.yaml specifies the beta version:flutter pub get to update.Callback URL mismatch error
Symptom: Error “redirect_uri_mismatch” from Auth0.Fix:- Verify Allowed Callback URLs in Auth0 Dashboard → Application Settings is exactly
auth0flutter://callback - Ensure the
appCustomURLparameter in your code matches:'auth0flutter://callback' - Check for trailing slashes or whitespace
Using an Intermediary Server
Using an Intermediary Server
When Auth0 redirects directly to a custom scheme, the browser may show a prompt or leave a blank tab. For a smoother experience, use an intermediary HTTPS server:The server page can display “Redirecting…” and close itself for a cleaner experience.
- Set up a server endpoint (e.g.,
https://your-app.example.com/callback) that redirects toauth0flutter://callback?code=...&state=... - In Auth0 Dashboard → Application Settings, set Allowed Callback URLs to
https://your-app.example.com/callback - Pass both URLs to the login method:
Custom Scopes and Audience
Custom Scopes and Audience
Request additional scopes or an API audience:Configure the API in Auth0 Dashboard → Applications > APIs before using the
audience parameter.Next Steps
- Auth0 Flutter SDK on GitHub — source code and issue tracker
- Auth0 Flutter SDK on pub.dev — API reference
- Flutter quickstart (Android, iOS, macOS, Web) — other platform guides
- Token Storage Best Practices — secure credential management
- Auth0 Universal Login — customize the login experience