2026年11月12日

2026年11月12日

Add Google Login to WordPress: OAuth Client and Plugin Setup

This article is a localized edition of the Japanese original. Read the Japanese original

Adding a "Sign in with Google" button to the WordPress login screen lets users log in with their Google account, so they no longer need to remember a separate WordPress password. It works through Google's OAuth 2.0 (OpenID Connect): you issue a client ID and secret on the Google side and enter them in a WordPress plugin.

Using "Log in with Google", a lightweight plugin that does only Google login, this article covers the Google Cloud setup, the WordPress setup and testing. Screen names are as of October 2026.

What you need

  • A WordPress site served over HTTPS (the Google OAuth client registers the URL users return to after login)
  • A Google account (to create a Google Cloud project)
  • A WordPress administrator account. Keep normal username-and-password login available in case Google login does not work

Choosing a plugin

These are the main plugins that add Google login. All of them are distributed on wordpress.org.

Plugin Characteristics
Log in with Google Lightweight plugin for Google login only. Few settings, and it can also be configured with constants in wp-config.php
Nextend Social Login and Register The free version supports Google, Facebook and X (formerly Twitter). Suited to adding several social logins at once
Site Kit by Google Google's official plugin. Besides Analytics and other integrations, it has a "Sign in with Google" feature

For an internal site or a site used only by administrators, Log in with Google is easy to handle because it has few settings. For a membership site that needs several social networks, consider Nextend Social Login. The steps below use Log in with Google.

Step 1: Create an OAuth client in Google Cloud

Sign in to the Google Cloud console and create a new project from the project picker at the top of the screen (an existing project also works).

Configure the consent screen (Google Auth Platform)

  1. Open "Google Auth Platform" from the menu and click "Get started"
  2. Enter the app name and the user support email address
  3. Choose the Audience. "Internal" is available only for projects that belong to a Google Workspace organization, and only users in that organization can log in. If the general public will use it, choose "External"
  4. Enter the contact email address, agree to the policy and create

If you chose "External", only the test users you add on the Audience screen can log in while the publishing status is "Testing". Once you have confirmed it works, publish the app to production from the same screen.

Create the OAuth client ID

  1. In "Google Auth Platform", open "Clients" and click "Create client"
  2. For the application type, choose "Web application"
  3. Under "Authorized redirect URIs", add the URL of the WordPress login page
https://example.com/wp-login.php

Replace example.com with your own domain. If WordPress lives in a subdirectory, register the actual login page URL, such as https://example.com/wp/wp-login.php. If even one character differs, Google shows a redirect_uri_mismatch error at login.

Click "Create" and the client ID and client secret are displayed. The secret may not be viewable later, so save it now.

Step 2: Install and configure the plugin

In the admin, go to Plugins → Add New Plugin, search for "Log in with Google", and install and activate the plugin by rtCamp. With WP-CLI:

wp plugin install login-with-google --activate

There are two ways to configure it.

  • Admin screen: open Settings → Login with Google, enter the "Client ID" and "Client Secret", and save
  • wp-config.php: define constants. The values are not stored in the database and cannot be changed from the admin, so this is the recommended method
<?php
// Add to wp-config.php above the "That's all, stop editing!" line
define( 'WP_GOOGLE_LOGIN_CLIENT_ID', 'your-client-id.apps.googleusercontent.com' );
define( 'WP_GOOGLE_LOGIN_SECRET', 'your-client-secret' );

// Optional: allow new users to be created via Google login
define( 'WP_GOOGLE_LOGIN_USER_REGISTRATION', true );

// Optional: email domains allowed to register (comma-separated)
define( 'WP_GOOGLE_LOGIN_WHITELIST_DOMAINS', 'example.com' );

Step 3: Decide how users are handled

Log in with Google looks up existing WordPress users by the Google account's email address (one verified by Google).

  • A user with the same email exists: the person is logged in as that user. The role stays as set in WordPress
  • No such user: a user is created if registration is allowed; otherwise the login is refused

Allow registration by checking "Create New User" on the settings screen or with the WP_GOOGLE_LOGIN_USER_REGISTRATION constant. When it is enabled, users are created through Google login even if "Anyone can register" under Settings → General is off. New users get the role set in "New User Default Role" under Settings → General.

For an internal site, enter your company's domain in "Whitelisted Domains" (or the WP_GOOGLE_LOGIN_WHITELIST_DOMAINS constant) so that only email addresses in that domain can register. Note that this restriction applies only to new registrations. Users who already exist in WordPress can log in with Google regardless of their domain.

Step 4: Test it

  1. Open https://example.com/wp-login.php in a private browser window and check that the login form shows a "Login with Google" button
  2. Click the button, choose a Google account and check that you are logged in to WordPress
  3. If you allowed registration, also try an account that does not exist in WordPress yet, and check the new user's role in the Users list

To place the button somewhere other than the login page, add the shortcode [google_login] to a page or similar.

If it does not work, check the following.

  • redirect_uri_mismatch: does the redirect URI registered with Google match the actual login page URL (https, with or without www, subdirectory)?
  • Google blocks access: the consent screen is still in "Testing" and the account you used is not a test user
  • "Registration is not allowed." is shown: registration is not enabled. Try a Google account whose email matches an existing user, or allow registration

Cautions

  • Do not put the client secret in theme files or a public repository. Keep it in a wp-config.php constant, and if you suspect a leak, issue a new secret in Google Cloud and replace it
  • Because existing users are matched by the Google account's email address, make sure administrator accounts use email addresses you control
  • Do not rely on Google login alone. Keeping password login for administrators lets you into the admin even if the Google configuration is wrong or Google has an outage
  • Turn on 2-Step Verification on the Google side for administrator accounts to reduce the risk of the Google account being taken over

Summary

  • In Google Cloud, set up the consent screen (Google Auth Platform) and an OAuth client (Web application), and register https://your-domain/wp-login.php as the redirect URI
  • Enter the client ID and secret in Log in with Google; constants in wp-config.php are recommended
  • Existing users are matched by email address. If you allow registration, check the domain restriction and the default role
  • While the publishing status is "Testing", only test users can log in. Publish to production after testing

Related articles

Questions about WordPress? The publisher of this site is based in Japan and replies in Japanese. Contact (Japanese)

お気軽にご相談ください

お見積りへ お問い合わせへ
▲