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)

Step 1: Sign Up for Auth0

  1. Navigate to auth0.com
  2. Click Sign up in the top right corner
  3. Choose to sign up with your Google account (recommended) or email
  4. Complete the registration process
  5. When prompted, choose a tenant domain (e.g., yourorg.auth0.com)
    • This becomes your AUTH0_DOMAIN
    • Choose carefully - this cannot be changed easily later
  6. Select your region (choose closest to your users)
  7. 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

  1. Log in to the Auth0 Dashboard
  2. Navigate to Applications > Applications from the left sidebar
  3. Click Create Application
  4. Enter an application name (e.g., "Production App")
  5. Select Regular Web Applications as the application type
  6. Click Create

Configure Application Settings

  1. Click on your newly created application to open its settings

  2. Note the following credentials (you'll need these for your .env file):

    • Domain - Your Auth0 tenant domain
    • Client ID - Your application's client identifier
    • Client Secret - Your application's secret key (click Show to reveal)
  3. Scroll down to Application URIs and configure the following:

    Allowed Callback URLs:

    https://app.rr.example.com/callback
    https://app.rr.example.com/auth/callback
    

    Replace app.rr.example.com with your actual SERVICE_DOMAIN.

    Allowed Logout URLs:

    https://app.rr.example.com
    https://app.rr.example.com/logout
    

    Allowed Web Origins:

    https://app.rr.example.com
    

    Allowed Origins (CORS):

    https://app.rr.example.com
    
  4. 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
    
  5. Scroll down to Advanced Settings > Grant Types

  6. Ensure the following are checked:

    • Authorization Code
    • Refresh Token
    • Implicit (if needed)
  7. 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)

  1. Navigate to Authentication > Social from the left sidebar
  2. Find Google / Gmail in the list
  3. Toggle the switch to enable it
  4. Click on Google / Gmail to open settings
  5. Under Applications, check your application name
  6. 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:

  1. Go to the Google Cloud Console

  2. Create a new project or select an existing one

  3. Navigate to APIs & Services > Credentials

  4. Click Create Credentials > OAuth 2.0 Client ID

  5. 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
  6. For Application type, select Web application

  7. Add Authorized redirect URIs:

    https://yourorg.auth0.com/login/callback
    

    Replace yourorg.auth0.com with your actual AUTH0_DOMAIN.

  8. Click Create and copy the Client ID and Client Secret

  9. Return to Auth0 Dashboard

  10. Navigate to Authentication > Social > Google / Gmail

  11. Enter your Google OAuth credentials:

    • Client ID - From Google Cloud Console
    • Client Secret - From Google Cloud Console
  12. Under Attributes, ensure the following are selected:

    • Basic Profile
    • Email address
  13. Under Permissions, ensure email and profile scopes are included

  14. Under Applications, check your application name

  15. Click Save

Step 4: Configure Application Branding (Optional)

Customize the Auth0 login experience to match your brand:

  1. Navigate to Branding > Universal Login in the Auth0 Dashboard
  2. Customize the following:
    • Logo - Upload your company logo
    • Primary Color - Set your brand color
    • Background Color - Customize the background
  3. 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

  1. Navigate to Applications > Applications
  2. Click on your application
  3. Under Basic Information:
    • Domain → AUTH0_DOMAIN
    • Client ID → AUTH0_CLIENT_ID
    • Client Secret → AUTH0_CLIENT_SECRET (click Show to reveal)

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

  1. Navigate to your application at https://app.rr.example.com (replace with your SERVICE_DOMAIN)
  2. Click the Login or Sign in with Google button
  3. You should be redirected to Auth0's Universal Login page
  4. Click Continue with Google
  5. Select or sign in with your Google account
  6. Grant permissions if prompted
  7. You should be redirected back to your application, now authenticated

Verify in Auth0 Dashboard

  1. Navigate to Monitoring > Logs in the Auth0 Dashboard
  2. You should see successful login events
  3. Navigate to User Management > Users
  4. 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):

  1. Navigate to Auth Pipeline > Rules (or Actions > Flows in newer Auth0 dashboards)
  2. Click Create Rule or Create Action
  3. 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);
}
  1. Save and enable the rule
  2. 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.)

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/callback vs https://app.example.com/callback/
  • Ensure you're using https:// in production (not http://)

"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

Additional Resources

Previous
Pusher
Next
S3