How to set up Google Login for Discourse
Once the Discourse site installation and hosting are complete, it is advisable to set up the login environment first. Discourse supports various login methods to make it easy for users to register and log in to the community. I prefer using Google accounts or Facebook and Apple accounts to log in rather than directly registering an account on the site.
Many people also prefer using their existing Google or Apple accounts for privacy protection and more convenient login. On this page, I will share how to set up the Google login environment for the Discourse site.
Create a project for a Google API service
To create a service for logging into a Google account on the Discourse website, access the Google Cloud page by logging in to the Discourse site.
Go to the main page and select the
[APIs & Services] menu.
[APIs & Services] page, click
[Select a project] at the top, then click the [NEW PROJECT] button.
Enter an easily identifiable name in the
[Project name] field, and click the
Create an OAuth consent screen
- Select the project you just created.
- From the left sidebar, choose
[OAuth consent screen].
- Check the User Type as
- Click the
- App name: Please enter the name of the website.
- User support email: Enter an email account where you can receive actual emails.
- Application home page: Enter the homepage address of the website where Google login will be applied.
- Application terms of service: Enter the link to the terms of service of the website.
- Authorized domains: Enter the domain address that has been registered in the Google Search Console.
- Developer contact information: Enter an email address where you can be contacted.
- Select the project you just created, then click on [Credentials] in the sidebar menu.
- On the Credentials page, click on the [CREATE CREDENTIALS] link at the top.
- Select OAuth client ID.
- Application type: Set the application type to [Web application].
- Name: Enter the name of the website where the application will be applied.
- Authorized redirect URIs: Add ‘/auth/google_oauth2/callback’ after the domain address where the API will be used.
OAuth client creation is complete. The above Client ID and Client secret will be used in the Discourse settings. You can verify them again in the Credentials menu of the project.
Publish your app
The app is currently in the testing state. You need to publish the app for Google account login on Discourse to work properly.
- Select the project, then choose
[OAuth consent screen]from the sidebar menu.
- In the Publishing status section, click
Enter your Google OAuth Client information in Discourse
①. Go to the Admin page.
②. Select the Settings tab.
③. Search for ‘google’ in the settings search bar.
④. Check the [enable google oauth2 logins] setting.
⑤. Enter the issued Client ID.
⑥. Enter the Client secret.
Now, try logging in on the Discourse website. If you see the [Sign in with Google] button, the configuration has been successfully completed.