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 , then click Select a project in the upper left corner.
![]()
New Project
On the right side of the top, click New Project.
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.
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.
Submit for Verification
Please follow the instructions in the 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.
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.
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.
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.
Obtain Key Pair
The client ID and secret will be displayed in the OAuth client dialog.
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.
The ID token will be verified by Discourse . The link above is the source code that Discourse uses for verification.
Please refer to the original article iSharkFly - 飞鲨 for more information.
Thanks for the official support.








