This guide explains how to set up Google login integration for your Discourse site by configuring OAuth2 credentials in the Google Cloud Console.
Required user level: Administrator
Overview
Google login allows users to sign in to your Discourse site using their Google accounts. This guide will walk you through:
- Creating a Google Cloud project
- Setting up OAuth consent
- Configuring credentials
- Enabling Google login in Discourse
Create a Google Cloud project
- Navigate to
https://console.developers.google.com
- Click “Select a project” in the top left
- Click “NEW PROJECT” in the top right
- Enter a project name and optionally edit the Project ID
- Click “Create”
If you see any errors after creating the project, refresh the page using Ctrl+F5.
Configure OAuth consent
- Select your project
- Navigate to “OAuth consent screen” in the left panel
- Select “External” and click “Create”
- Fill in the application details:
- Enter your application name
- Add your domain under authorized domains
- Configure user support email
- Add developer contact information
As of September 13, 2021, Google requires HTTPS for all OAuth implementations.
Set up credentials
- Go to the “Credentials” tab
- Click “+ CREATE CREDENTIALS” and select “OAuth client ID”
- Configure the OAuth client:
- Select “Web application” as the Application Type
- Add your site’s base URL under Authorized JavaScript Origins (including
https://
) - Add your callback URL under Authorized Redirect URIs:
https://your-discourse-site.com/auth/google_oauth2/callback
- Click “Create”
- Save the provided client ID and client secret
Configure Discourse settings
- In your Discourse admin settings:
- Enable the setting
enable google oauth2 logins
- Enter your
google oauth2 client id
- Enter your
google oauth2 client secret
- Enable the setting
Verify and publish
- Test the integration while in “Testing” status by adding a Google user
- To make the integration publicly available:
- Change the status to “In production”
- Complete Google’s verification process
- Verify site ownership through Google Search Console
Additional configuration
G Suite login
To restrict login to specific G Suite domains:
- Enable the
google oauth2 hd
site setting - Enter your G Suite domain
Troubleshooting
If you experience login issues:
- Verify that HTTPS is properly configured
- Double-check all redirect URIs
- Ensure your site’s SSL certificate is valid
- Confirm that all required Google Cloud APIs are enabled
Related resources
- Utilizzo di OAuth 2.0 per applicazioni server web | Authorization | Google for Developers
- Perform Google Search Console Verification with Discourse
Last edited by @jessii 2024-11-21T18:29:20Z
Check document
Perform check on document: