Skip to main content

Logging in with Google

Members log in with their Google account, a Gmail address or a Google Workspace one. Setting it up takes about ten minutes: an app in the Google Cloud console, its keys in Poly Community, turning it on, then a test.

You need a Google account to make the app with, and your site on https. Google sends members back only to https addresses.

How single sign-on works for every provider, and what each setting does, is on Single sign-on.

1. Copy the redirect address​

  1. In WordPress, go to Poly Community → Settings → Services → Single sign-on.
  2. Press Set up on the Google row.
  3. Copy the Redirect address at the top of the dialog. It looks like https://example.com/wp-json/wordplus/v1/sso/back.
Services, Single sign-on: each provider with Set up, Add a provider and the redirect address
Settings → Services → Single sign-on

Leave the dialog open. Make the app in it opens the Google Cloud console for the next step.

2. Make the app in Google Cloud​

  1. Open the Google Cloud console and log in with the Google account that will own the app.

  2. Pick a project, or make one for your site with Select a project, then New project.

  3. Open Google Auth Platform. The first time, press Get started and fill in:

    • App Information: the App Name, the name of your community, and a User support email members can write to.
    • Audience: External, so any Google account can log in. Choose Internal only if every member has an account in your own Google Workspace.
    • Contact Information: your email address, for messages from Google.
  4. Go to Clients and press Create client.

  5. For Application type, choose Web application, and give it a name, such as your site name.

  6. Under Authorized redirect URIs, press Add URI and paste the redirect address from step 1. It has to match exactly. You do not need Authorized JavaScript origins.

    Create OAuth client ID: Web application, the name, and the redirect address under Authorized redirect URIs
    Google Cloud console → Google Auth Platform → Clients → Create client
  7. Press Create. Google shows the Client ID and the Client secret. Copy both now: Google shows the full secret only this once. Later the page of the client shows the Client ID and only the last four characters of the secret. If the secret is lost, press Add secret there for a new one.

    The page of the client: the Client ID, and under Client secrets only the last four characters of the secret, with Add secret
    Google Cloud console → Google Auth Platform → Clients → the client

3. Enter the keys​

  1. Back in the dialog in WordPress, paste them into Client ID and Client secret.

    The Google dialog: Make the app, the redirect address, Client ID, Client secret, Let new people join with it and Only these domains can join
    The Google dialog, in Settings → Services → Single sign-on
  2. Decide who may use it with Let new people join with it. Leave it off if only people who already have an account on your site may log in with Google. Turn it on if anyone with a Google account may join your community. See Let new people join with it.

  3. With it on, Only these domains can join shows. Leave it empty for any Google account, or enter your domain, such as example.com, so only addresses of your company Google Workspace can join.

  4. Press Save the provider. The Google row now says Set up and Off: members do not see it yet.

4. Turn it on​

  1. Press Turn it on on the Google row, which opens Settings → Joining → Logging in.
  2. Turn Google on with its switch, and press Save changes.
Joining, Logging in: Google turned on among the single sign-on providers
Settings → Joining → Logging in

Continue with Google now shows on the login form of the community and on the WordPress login screen. With Let new people join with it on, it shows on the sign-up forms too. With it off it does not, as Google then logs in only people who already have an account.

The WordPress login screen with a Continue with Google button
The WordPress login screen

5. Try it​

Poly Community asks Google only for the name, email address and picture of an account, the scopes openid, email and profile. For these Google lets every Google account log in while the app is still Testing, with no list of test users and no warning screen, so you can try it straight away. The Audience page of the console says that only test users can use an app in Testing, but Google makes an exception for apps that ask only for these three, as its help on publishing status explains.

  1. In a private window, open the login page of your site and press Continue with Google.
  2. Pick a Google account. Google asks to share its name, email address and picture with your site.
  3. You are back on your site. A member is logged in, someone new is on the sign-up form, and anything else lands on the login page with a line that says why.

Try your own account too. If your account on the site has the same address as your Google account, the login page asks you to log in once with your password, and from then on Google logs you straight in. An account that already has the address explains why.

6. Publishing the app, if you want to​

The app can stay in Testing: with only these three scopes, members log in either way. While it is in Testing, the Google screen says Choose an account to continue to your domain, such as example.com. Publish it if you want Google to show the name and logo of your app there instead. That takes two steps:

  1. On Google Auth Platform → Branding, under App domain, fill in the Application home page and the Application privacy policy link, both on your own domain, and press Save. Google asks for these links before an app goes into production. While they are empty, Publish app on the Audience page is greyed out, with a line that sends you to the Branding page.

    Branding, App domain: the Application home page, the Application privacy policy link and the authorized domain filled in
    Google Cloud console → Google Auth Platform → Branding
  2. On Google Auth Platform → Audience, press Publish app and confirm. The app is then In production.

    Audience: Publishing status Testing with Publish app greyed out until the Branding page is complete, and User type External
    Google Cloud console → Google Auth Platform → Audience

Google shows the name and logo only after it has verified your brand. Until then the Google screen names your domain.

What Google gives your site​

The ID of the Google account, the name, the email address and whether Google confirmed it, and the picture. Poly Community asks for the picture at 640 pixels and makes it the picture of a new member, unless it is the blank letter Google shows for an account without a photo. Members who already had an account keep their own picture.

When something goes wrong​

Google says redirect_uri_mismatch​

The redirect address in the Google app is not exactly the one in WordPress. Copy it again from the Google dialog in Services → Single sign-on and paste it under Authorized redirect URIs, with nothing added or left out: the same https, the same www or none, no slash at the end. A change in Google can take a few minutes to apply.

Google blocks an account that is not a test user​

Google should not do this for Poly Community, as it asks only for the name, email address and picture. If it does, add the account to the test users under Google Auth Platform → Audience, or publish the app (step 6).

Anything else​

A Forbidden page from your host right after Google, a login that always says it took too long, or a button that does not show: these happen with every provider and are on Common problems.