Add Social Login

Learn how to add "Sign in with Google" to your application in under 10 minutes.

What You'll Build

By the end of this tutorial, you'll have:

  • Google OAuth configured in Authority

  • A working "Sign in with Google" button

  • Users automatically created from Google accounts

Prerequisites

  • Authority running locally or deployed

  • A Google account for testing

  • Basic web development knowledge

Step 1: Create a Google OAuth App

  1. Create a new project:

    • Click the project dropdown at the top

    • Click New Project

    • Name it (e.g., "My App Auth")

    • Click Create

  2. Enable the OAuth consent screen:

    • Navigate to APIs & Services > OAuth consent screen

    • Select External user type

    • Click Create

    • Fill in required fields:

      • App name: Your app name

      • User support email: Your email

      • Developer contact: Your email

    • Click Save and Continue through remaining steps

  3. Create OAuth credentials:

    • Navigate to APIs & Services > Credentials

    • Click Create Credentials > OAuth client ID

    • Application type: Web application

    • Name: "Authority Integration"

    • Authorized redirect URIs: http://localhost:4000/auth/google/callback

    • Click Create

  4. Copy your Client ID and Client Secret

Step 2: Configure Authority

  1. Log in to your Authority admin dashboard at http://localhost:4000/dashboard

  2. Navigate to Settings > Social Login

  3. Find the Google section and configure:

    • Toggle Enable Google OAuth to ON

    • Paste your Client ID

    • Paste your Client Secret

  4. Click Save

Step 3: Test the Integration

  1. Open a new incognito/private browser window

  2. Navigate to http://localhost:4000/auth/google

  3. You should be redirected to Google's sign-in page

  4. Sign in with your Google account

  5. After approval, you'll be redirected back to Authority

  6. Check the admin dashboard - a new user should appear!

Step 4: Add to Your Application

Add a sign-in button to your app:

Step 5: Handle the Redirect

After successful authentication, redirect users to your app:

After authentication, Authority will redirect users to your specified URL with an active session.

What Happens Behind the Scenes

spinner

Adding More Providers

Now that Google is working, add more providers:

Common Issues

"redirect_uri_mismatch"

Your callback URL doesn't match Google's configuration.

Fix: Ensure the redirect URI in Google Console exactly matches:

"Access blocked: App not verified"

You're not a test user for an unverified app.

Fix: In Google Console, go to OAuth consent screen > Test users and add your email.

User Created But No Session

Check that your forward_url is correctly encoded.

Fix: Use btoa() to Base64 encode the URL.

Next Steps

Last updated

Was this helpful?