Skip to main content
Google Authenctication

Integrating Google Login with Drupal 10

Why Google Login in Drupal?

Integrating Google Sign-In allows users to log in using their existing Google account, which results in:

  • Faster registration & login

  • Reduced password fatigue

  • Better security (OAuth 2.0)

  • Higher conversion rates

Drupal 10 supports this via contributed OAuth modules.

Approach 1: Google Login Using Social Auth Google (Recommended)

Why choose Social Auth Google?
  • Built on Drupal Social Auth framework

  • Clean Drupal Entity-based configuration

  • Fully extensible (custom fields, roles, workflows)

  • Best for enterprise & custom Drupal projects

Step 1: Create Google OAuth Credentials
  1. Go to Google Cloud Console

  2. Create a New Project

  3. Navigate to:
    APIs & Services -> Credentials

  4. Click Create Credentials -> OAuth Client ID

  5. Application type: Web application

  6. Authorized redirect URI:

    https://yourdomain.com/user/login/google/callback
    
  7. Save Client ID and Client Secret

Step 2: Install Required Drupal Modules

Install using Composer:

composer require drupal/social_auth drupal/social_auth_google

Enable modules:

drush en social_auth social_auth_google -y
Step 3: Configure Social Auth Google

Navigate to: 

Admin → Configuration → People → Social Auth → Google
Configuration Fields
  • Client ID: Provided from the Google Cloud Console

  • Client Secret: Provided from the Google Cloud Console

  • Scopes: email, profile

  • Redirect URI: Auto-generated by Drupal

  • Button Text: Login with Google

Step 4: Enable User Registration

Ensure Drupal allows new users:

Admin → Configuration → People → Account settings

Set:

  • Who can register accounts? → Visitors

Step 5: Place Google Login Button

Social Auth does not auto-place buttons.

Option A: Use Block (Recommended)
  1. Go to:

Admin → Structure → Block layout
  1. Place Social Auth Login block
  2. Assign region (Sidebar / Content)
  3. Save
Option B: Twig Template (Custom Theme)
<a href="/user/login/google" class="google-login-btn">
  Login with Google
</a>
Step 6: Test Login Flow
  1. Open /user/login

  2. Click Login with Google

  3. Authenticate via Google

  4. User is:

    • Auto-created in Drupal

    • Logged in immediately

    • Email mapped automatically

Step 7: Map Roles & User Data (Optional)

Install helper module:

composer require drupal/social_auth_extra

Allows:

  • Assign Drupal roles to Google users

  • Map Google profile fields → Drupal user fields

Approach 2: Google Login Using OAuth Login (MiniOrange)

When to choose OAuth Login?
  • UI-driven setup

  • No custom coding

  • Suitable for quick setups & POCs

Step 1: Install OAuth Login Module
composer require drupal/miniorange_oauth_client
drush en miniorange_oauth_client -y
Step 2: Configure Google OAuth Provider

Navigate to:

Admin → Configuration → OAuth Client

Steps:

  1. Select Google as provider

  2. Enter:

    • Client ID

    • Client Secret

  3. Save & Test connection

Step 3: Attribute & Role Mapping

Configure:

  • Email - Drupal Email

  • Name - Username

  • Default role - Authenticated User / Custom role

Step 4: Display Login Button

Module provides:

  • Shortcode

  • Block

  • Auto-login button on /user/login