# Configure Google login in Discourse

**URL:** https://meta.discourse.org/t/configure-google-login-in-discourse-discourse-google/197635
**Category:** Administrators
**Tags:** sso, chinese-translation, how-to
**Created:** [July 19, 2021, 10:04pm UTC](https://meta.discourse.org/t/configure-google-login-in-discourse-discourse-google/197635 "2021-07-19T22:04:14Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![honeymoose](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/honeymoose/32/198718_2.png) [@honeymoose](https://meta.discourse.org/u/honeymoose)
#### Post date: [July 19, 2021, 10:04pm UTC](https://meta.discourse.org/t/configure-google-login-in-discourse-discourse-google/197635/1 "2021-07-19T22:04:14Z")

</div>

This article shows how to configure registration in Discourse to use Google OAuth2 for login.

## Google Console Configuration

Go to [https://console.developers.google.com](https://console.developers.google.com/), then click **Select a project** in the upper left corner.

![image](https://global.discourse-cdn.com/meta/original/3X/5/3/53ffdc42f439ea96246c17c14cdb39b1cf7ffa17.png)

## New Project

On the right side of the top, click **New Project**.

 ![image](https://global.discourse-cdn.com/meta/original/3X/d/3/d3e144aecc6111d123833b5cd909fb55772a7906.png)

## Enter Project Information

Enter the project name in the **Project Name** field. You can also edit the **Project ID**.

Editing the project ID is optional. Then click **Create**.

This operation may take some time, so you may need to wait patiently.

 ![image](https://global.discourse-cdn.com/meta/original/3X/e/1/e13039c11648f8b5737ab5cee4b15e56801cfbe6.png)

### Creation Error

During the creation process, an error may occur.  
In this case, you can choose to ignore the creation error and then click Ctrl+F5 to refresh.

 ![image](https://global.discourse-cdn.com/meta/original/3X/4/0/406ea51dde44c2035b9b885031b26348b9f8bd33.png)

### Submit for Verification

Please follow the instructions in the [https://support.google.com/cloud/answer/9110914#submit-app-ver](https://support.google.com/cloud/answer/9110914#submit-app-ver) link to submit your project to the Google Cloud Platform for verification.

## Create External Link

In your project, select the current project name, then click the **OAuth consent screen** menu in the left control panel, then select **External** , and then click the Create button.

 ![image](https://global.discourse-cdn.com/meta/original/3X/1/7/176c04aaac650242ecc948d5716c56653f9808ce.png)

## Fill in All Data

We recommend that you fill in all the data completely before clicking the Save button to save.

In the example, we assume our domain name is `https://demo.site.com`. Please ensure that the URL you enter starts with the `https` or `http` protocol.

ℹ Starting from 2021/09/13 (September 13), Google will require all websites accessing Google services to use https.

For **Application logo** , no modification is required. Of course, you can also upload your own logo. Google will then verify the site.

 ![image](https://global.discourse-cdn.com/meta/original/3X/c/8/c88b715d4beb2c189e89398f7afd939d43a650ad.png)

 ![image](https://global.discourse-cdn.com/meta/original/3X/c/2/c22a54363d32e391c15f5910bf8fba5230e2a479.png)

## Credentials

Next, you need to create Credentials. Go to the **Credentials** tab on the left, then click the + CREATE CREDENTIALS button, and then select **OAuth client ID** to create.

 ![image](https://global.discourse-cdn.com/meta/original/3X/c/e/ced6cb85ff4a9e0bb3f0f617fc6880b1a74f8b09.png)

## Select Type

In the subsequent interface, select **Web application** as the authorization type for _Application Type_.

In the _Authorized JavaScript Origins_ interface, add your website URL. Please note that this website URL must start with `http://` or `https://`.

In the _Authorized Redirect URI_ section, you need to add `/auth/google_oauth2/callback` after the URL you entered previously.

Then click the Create button to create.

ℹ Please note that starting from 2021/09/13 (September 13), Google will require all websites accessing Google services to use https. Therefore, your Discourse website should use https as much as possible.

 ![firefox_2020-03-12_19-04-54](https://global.discourse-cdn.com/meta/original/3X/2/3/2336c82222a35d1a88232c5baa8ead24bd5f2345.png)

## Obtain Key Pair

The client ID and secret will be displayed in the OAuth client dialog.

 ![image](https://global.discourse-cdn.com/meta/original/3X/2/a/2a2b5decdaf8f51ea0629dbb6f392ed9c1c312eb.png)

## View Key Pair (Optional)

This step is optional. Now, from your project, click the **Credentials** option, and you can find the OAuth keys to edit or delete them.

## Discourse Configuration

In your Discourse configuration, click `enable google oauth2 logins`, then enter the `google oauth2 client id` and `google auth2 client secret` you obtained in the steps above.

And enter the key pair above into the correct configuration dialog box.

At this point, the configuration for Google login should be complete.

You can test it through the Discourse frontend.

### Tips

For enabling Gsuite login configuration, use the configuration parameter `google oauth2 hd`. For more information, please visit [here](https://developers.google.com/identity/protocols/OpenIDConnect#hd-param).

The ID token will be verified by [Discourse](https://github.com/zquestz/omniauth-google-oauth2/blob/master/lib/omniauth/strategies/google_oauth2.rb#L213-L224). The link above is the source code that Discourse uses for verification.

Please refer to the original article [iSharkFly - 飞鲨](https://www.ossez.com/t/discourse-google-google-login/13582) for more information.

Thanks for the official support.
