Provider – Google

Google Sample

Table of contents

How to enable Google login in WordPress

1. App creation

To be able to log in via Google you must create a Google app first.

  1. Navigate to https://console.developers.google.com/apis/
  2. Log in with your Google credentials if you are not logged in
  3. If you don’t have a project yet, you’ll need to create one. You can do this by clicking on the blue “Create project” button on the right side! ( If you already have a project, click on the name of your project in the dashboard instead, which will bring up a modal and click New Project. )
  4. Click the Create button.
  5. Name your project and then click on the Create button again
  6. Once you have a project, you’ll end up in the dashboard.
  7. Click on the “Credentials” in the left hand menu to create new API credentials
  8. Select the OAuth consent screen!
  9. Enter a name for your App under the “Application name” field, which will appear as the name of the app asking for consent.
  10. Fill the “Authorized domains” field with your domain name. For example if the URL of your site is http://yoursite.com/ then your domain will be yoursite.com !
  11. Press “Save” and you will be redirected back to Credentials screen.
  12. Click the Create credentials button and select “OAuth client ID” from the dropdown.
  13. Your application type should be “Web application”
  14. Name your application
  15. Add the following URL to the “Authorised redirect URIs” field: http://yoursite.com/wp-login.php?loginSocial=google where yoursite.com is your site’s URL
  16. Click on the Create button
  17. A modal should pop up with your credentials. If that doesn’t happen, go to the Credentials in the left hand menu and select your app by clicking on its name and you’ll be able to copy-paste the Client ID and Client Secret from there.

2. App setup

Once your Google app is ready you’ll need to copy and paste the Client ID and Client Secret to the Google provider’s Settings tab. You can find the information at your Google app’s Settings which you can reach from the left sidebar.

3. Verification

Once your Client ID and Client Secret has been added you need to verify the setup first. This verification helps you identify possible problems with the app.

Settings

Google Provider Configuration

Client ID

The Client ID of your Google app. You can find it at left menu: Credentials → select your App.

Client Secret

The Client Secret of your Google app. You can find it at left menu: Credentials → select your App.

Google Provider Configuration

Username prefix on Register

Whenever a new user registers with their Google account they can get a custom prefix so you can easily identify them.

Fallback username prefix on register

Whenever a new user registers with their Google account and we can not generate a valid username from the first name or last name, a random username will be generated. With this option they can get a custom prefix so you can easily identify them.

Terms and conditions

This option can only be seen, if Terms and conditions is set to Show in Global Settings → Privacy tab. Here you can set custom Terms and Conditions for users who register with Google. For more information please read our GDPR documentation.

Sync data

By default Nextend Social Login stores the first name, last name, email, avatar url and access token if it is possible, however some additional information can also be retrieved and stored.
When an option is checked, that field will be stored in a meta key with the specified name.

Google Sync data

Sync fields

It determines when the synchronization shall happen.

  • Register: whenever a new user registers with a provider, their data will be retrieved and stored.
  • Login: whenever user logs in with a provider, their data will be retrieved and stored.
  • Link: whenever user links and existing WordPress account with a provider, their data will be retrieved and stored.

Gender

Stores the user’s gender.

Profile link

Stores the user’s Google+ profile link.

Locale

Stores the user’s locale.

Introduction*

Stores the user’s introduction Google+.

Birthday*

Stores the user’s birthday.

Occupation*

Stores the user’s occupation.

Organizations*

Stores the user’s organization information ( name, title, type, start date, end date, is that current).

Places lived*

Stores the place where the user lives or where used to live in the past.

Tag line*

Stores the user’s tag line.

For fields marked with * it is essential to enable Google+ API in your project!
  • Navigate to Google API Console
  • Select your existing Google APP on the top left corner with the “Select a project” option, if you have not selected it yet.
  • Type “Google+ Api” in search field and click on the one called “Google+ Api”!
  • By pressing “Enable” button, your App is done!

Google Sign-In Branding Guidelines compatibility

According to the Google Sign-In Branding Guidelines, the button need to comply with some requirements. At the buttons tab of the Google provider, there are predefined skins, which comply with those requirements.
Google Buttons

Common error messages returned by Google during verification

redirect_uri_mismatch

Error: redirect_uri_mismatch
The redirect URI in the request, https://yoursite.com/wp-login.php?loginSocial=google, (where the yoursite.com is your domain) does not match the ones authorized for the OAuth client.

The problem is that the entered Authorized redirect URIs field is not correct for your app. Check the 15th step of the App setup to fix the problem.

invalid_client

Error: invalid_client The OAuth client was not found.

The entered Client ID is not correct. Maybe the app with the entered ID was deleted. Go to the Google provider → Settings and make sure that an existing App’s Client ID and Client Secret was entered.

Request is missing required authentication credential

Error: Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.

The entered Client ID or Client Secret is not correct, it is probably contain some extra white-space characters. Make sure you copied the Client ID and the Client Secret in the appropriate format.

403 and 404 error

When your other providers work properly, but your Google provider gives you 403 or 404 error, your server or firewall will most likely have a limitation that prevents accessing to pages with HTTP/HTTPS links in them. For more information please visit our Google 403 and 404 errors documentation.