Requirements
Auth0
Single sign-on with Google accounts through Auth0, from application settings to troubleshooting.
This document describes how to set up Auth0 for Single Sign-On (SSO) authentication using Google/Gmail accounts.
Overview
The application uses Auth0 to provide Single Sign-On functionality. Currently, only Google/Gmail authentication is supported. Users can log in with their Google accounts without creating separate application credentials.
Environment Configuration
Once you have followed the steps below, you will add the following credentials
to your .env file:
AUTH0_DOMAIN=yourorg.auth0.com
AUTH0_CLIENT_ID=xxxxxxxxxxxxxxxxxxx
AUTH0_CLIENT_SECRET=xxxxxxxxxxxxxxxxxxxxxxx
Prerequisites
- A Google account (for Auth0 signup)
- Your deployment domains:
- ROOT_DOMAIN - The root domain of your deployment (e.g.,
rr.example.com) - SERVICE_DOMAIN - The domain where your app is served (e.g.,
app.rr.example.com)
- ROOT_DOMAIN - The root domain of your deployment (e.g.,
Step 1: Sign Up for Auth0
- Navigate to auth0.com
- Click Sign up in the top right corner
- Choose to sign up with your Google account (recommended) or email
- Complete the registration process
- When prompted, choose a tenant domain (e.g.,
yourorg.auth0.com)- This becomes your AUTH0_DOMAIN
- Choose carefully - this cannot be changed easily later
- Select your region (choose closest to your users)
- Complete the onboarding questionnaire
Tenant Domain Format: Your tenant domain will look like yourorg.auth0.com
or yourorg.us.auth0.com depending on your region.
Step 2: Create an Application
- Log in to the Auth0 Dashboard
- Navigate to Applications > Applications from the left sidebar
- Click Create Application
- Enter an application name (e.g., "Production App")
- Select Regular Web Applications as the application type
- Click Create
Configure Application Settings
-
Click on your newly created application to open its settings
-
Note the following credentials (you'll need these for your
.envfile):- Domain - Your Auth0 tenant domain
- Client ID - Your application's client identifier
- Client Secret - Your application's secret key (click Show to reveal)
-
Scroll down to Application URIs and configure the following:
Allowed Callback URLs:
https://app.rr.example.com/callback https://app.rr.example.com/auth/callbackReplace
app.rr.example.comwith your actual SERVICE_DOMAIN.Allowed Logout URLs:
https://app.rr.example.com https://app.rr.example.com/logoutAllowed Web Origins:
https://app.rr.example.comAllowed Origins (CORS):
https://app.rr.example.com -
For local development, also add:
http://localhost:8000/callback http://localhost:8000/auth/callback http://localhost:8000 http://127.0.0.1:8000/callback http://127.0.0.1:8000/auth/callback http://127.0.0.1:8000 -
Scroll down to Advanced Settings > Grant Types
-
Ensure the following are checked:
- Authorization Code
- Refresh Token
- Implicit (if needed)
-
Click Save Changes at the bottom
Step 3: Configure Google Social Connection
Auth0 provides a default Google connection, but you should configure it for production use.
Option A: Use Auth0's Development Keys (Testing Only)
- Navigate to Authentication > Social from the left sidebar
- Find Google / Gmail in the list
- Toggle the switch to enable it
- Click on Google / Gmail to open settings
- Under Applications, check your application name
- Click Save
Warning: Auth0's development keys are for testing only and have limitations. Always use your own Google OAuth credentials for production.
Option B: Use Your Own Google OAuth Credentials (Production)
For production deployments, you should create your own Google OAuth application:
-
Go to the Google Cloud Console
-
Create a new project or select an existing one
-
Navigate to APIs & Services > Credentials
-
Click Create Credentials > OAuth 2.0 Client ID
-
Configure the OAuth consent screen if prompted:
- User Type: External
- App name: Your application name
- User support email: Your support email
- Developer contact: Your email
-
For Application type, select Web application
-
Add Authorized redirect URIs:
https://yourorg.auth0.com/login/callbackReplace
yourorg.auth0.comwith your actual AUTH0_DOMAIN. -
Click Create and copy the Client ID and Client Secret
-
Return to Auth0 Dashboard
-
Navigate to Authentication > Social > Google / Gmail
-
Enter your Google OAuth credentials:
- Client ID - From Google Cloud Console
- Client Secret - From Google Cloud Console
-
Under Attributes, ensure the following are selected:
- Basic Profile
- Email address
-
Under Permissions, ensure email and profile scopes are included
-
Under Applications, check your application name
-
Click Save
Step 4: Configure Application Branding (Optional)
Customize the Auth0 login experience to match your brand:
- Navigate to Branding > Universal Login in the Auth0 Dashboard
- Customize the following:
- Logo - Upload your company logo
- Primary Color - Set your brand color
- Background Color - Customize the background
- Click Save Changes
You can also customize the entire login page using the Advanced tab if needed.
Step 5: Set Up Environment Variables
Add the following credentials to your .env file:
# Auth0 Configuration
AUTH0_DOMAIN=yourorg.auth0.com
AUTH0_CLIENT_ID=your_client_id_here
AUTH0_CLIENT_SECRET=your_client_secret_here
Finding Your Credentials
- Navigate to Applications > Applications
- Click on your application
- Under Basic Information:
- Domain →
AUTH0_DOMAIN - Client ID →
AUTH0_CLIENT_ID - Client Secret →
AUTH0_CLIENT_SECRET(click Show to reveal)
- Domain →
Security Note: Never commit these credentials to version control. Always use environment variables.
Domain Configuration Checklist
Before going live, ensure your domains are correctly configured:
- [ ] ROOT_DOMAIN DNS is configured and pointing to your infrastructure
- [ ] SERVICE_DOMAIN DNS is configured (e.g.,
app.rr.example.com) - [ ] SSL/TLS certificates are installed for both domains
- [ ] Auth0 Allowed Callback URLs include your SERVICE_DOMAIN
- [ ] Auth0 Allowed Logout URLs include your SERVICE_DOMAIN
- [ ] Auth0 Allowed Web Origins include your SERVICE_DOMAIN
- [ ] Google OAuth redirect URIs include your AUTH0_DOMAIN (if using custom credentials)
Testing Your Configuration
Test the Authentication Flow
- Navigate to your application at
https://app.rr.example.com(replace with your SERVICE_DOMAIN) - Click the Login or Sign in with Google button
- You should be redirected to Auth0's Universal Login page
- Click Continue with Google
- Select or sign in with your Google account
- Grant permissions if prompted
- You should be redirected back to your application, now authenticated
Verify in Auth0 Dashboard
- Navigate to Monitoring > Logs in the Auth0 Dashboard
- You should see successful login events
- Navigate to User Management > Users
- Your test user should appear in the list
Restricting Access to Specific Domains
If you want to restrict authentication to specific Google Workspace domains
(e.g., only @yourorg.com emails):
- Navigate to Auth Pipeline > Rules (or Actions > Flows in newer Auth0 dashboards)
- Click Create Rule or Create Action
- Use a template or create a custom rule:
function emailDomainWhitelist(user, context, callback) {
const whitelist = ['yourorg.com', 'partner.com'];
const userHasAccess = whitelist.some((domain) => {
const emailSplit = user.email.split('@');
return emailSplit[emailSplit.length - 1].toLowerCase() === domain;
});
if (!userHasAccess) {
return callback(
new UnauthorizedError(
'Access denied. Please use a company email address.'
)
);
}
return callback(null, user, context);
}
- Save and enable the rule
- Test with accounts from allowed and disallowed domains
Pricing and Limits
Free Tier
- 7,500 monthly active users (MAUs)
- Unlimited logins
- Community support
- Social connections (Google, Facebook, etc.)
Paid Plans
If you exceed the free tier limits, you'll need to upgrade:
- Essentials - Starts at $35/month for additional MAUs
- Professional - Advanced features, starts at $240/month
- Enterprise - Custom pricing for large deployments
Monitor your usage in the Auth0 Dashboard under Monitoring > Usage.
Troubleshooting
"Callback URL mismatch" Error
- Verify the callback URL in your application matches exactly what's configured in Auth0
- Check for trailing slashes -
https://app.example.com/callbackvshttps://app.example.com/callback/ - Ensure you're using
https://in production (nothttp://)
"Access Denied" After Google Login
- Check Auth0 Logs for specific error messages
- Verify your application is enabled in the Google social connection
- Ensure email and profile scopes are requested
- Check if any rules are blocking authentication
"Invalid State" Error
- This often indicates a session issue
- Clear browser cookies and try again
- Verify your application's session management is configured correctly
- Check that your domains match between Auth0 and your application
Users Not Appearing in Dashboard
- Check Monitoring > Logs for authentication events
- Verify the login completed successfully
- Ensure you're looking at the correct Auth0 tenant
- Check if any rules are modifying or rejecting users
Google Social Connection Not Working
- Verify the Google connection is enabled and toggled ON
- Check that your application is selected in the connection settings
- If using custom Google credentials, verify they're entered correctly
- Ensure the Auth0 callback URL is added to Google Cloud Console
Security Best Practices
- Rotate credentials regularly - Change Client Secret periodically
- Use HTTPS exclusively - Never use Auth0 over HTTP in production
- Enable Multi-Factor Authentication - Configure MFA for administrative users
- Monitor authentication logs - Regularly review logs for suspicious activity
- Implement rate limiting - Use Auth0's anomaly detection features
- Keep URLs restricted - Only add necessary callback URLs
- Use custom Google credentials - Don't rely on Auth0's development keys in production