Add your Firebase configuration to appsettings.json:
{
"FirebaseConfig": {
"apiKey": "xxxx",
"authDomain": "xxxx.firebaseapp.com",
"projectId": "xxxx",
"storageBucket": "xxxx.appspot.com",
"messagingSenderId": "xxxx",
"appId": "1:xxxx:web:xxxx",
"measurementId": "G-XXXX",
"providers": ["google", "facebook", "apple", "microsoft"],
"enableSmsMfa": true
}
}Generate and configure your Firebase service account private key:
- Navigate to your Firebase project in the Firebase console
- Open Project settings
- Select the Service accounts tab
- Click Generate new private key in the Firebase Admin SDK section
- Confirm to download the JSON key file
- Add the JSON file to your project (e.g., in a
keysfolder) - Configure the file to copy to output directory in your project settings
Configure the Firebase email template action URL to redirect to your Xams application:
- Navigate to Authentication → Templates in the Firebase console
- Select an email template and click Edit Template
- Click Customize action URL
- Set the URL to your application's action handler (e.g.,
https://localhost:3000/__/auth/action)
This URL handles email verification, password reset, and other Firebase authentication actions.
Setup Instructions: Follow Google Cloud Console OAuth setup to configure each provider.
Critical for Custom Domains: Add authorized redirect URIs:
https://YOUR_CUSTOM_DOMAIN/__/auth/handler (Production)
https://localhost:PORT/__/auth/handler (Development)
The /__/auth/handler endpoint is automatically provided by Xams (app.AddFirebaseAuthProxy()), implementing Firebase's redirect best practice Option 3 - proxying auth through your backend. This is required for custom domains with Google OAuth.
Configure the Firebase email template action URL to redirect to your Xams application:
- Navigate to Authentication → Templates in the Firebase console
- Select an email template and click Edit Template
- Click Customize action URL
- Set the URL to your application's action handler (e.g.,
https://localhost:3000/__/auth/action)
This URL handles email verification, password reset, and other Firebase authentication actions.
In Program.cs, with useAuth = true, navigate to the admin dashboard to verify Firebase authentication is working:
Example: https://localhost:7102/xams
You should see the Firebase login page with your configured authentication providers.