إعداد تسجيل الدخول إلى Google لمنصة Discourse

:bookmark: This guide explains how to set up Google login integration for your Discourse site by configuring OAuth2 credentials in the Google Cloud Console.

:person_raising_hand: 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:

  1. Creating a Google Cloud project
  2. Setting up OAuth consent
  3. Configuring credentials
  4. Enabling Google login in Discourse

Create a Google Cloud project

  1. Navigate to https://console.developers.google.com
  2. Click the project selection button in the top left
  3. Click “New Project”

  1. Enter a project name and optional location.
  2. Click “Create”

:information_source: If you see any errors after creating the project, refresh the page using Ctrl+F5.

Configure OAuth consent

  1. Navigate back to https://console.developers.google.com and select your new project if it is not already slected.
  2. Navigate to “OAuth consent screen” in the left panel. You can also use the top left Google Cloud menu to select “APIs & Services” → “Oauth consent screen”.

  1. Click “Get Started”
  2. Under “App Information” enter an app name and select a user-support email address.

  1. Select “External” Audience

  1. Next, enter a notifications email address
  2. Finally, accept the API Services: User Data Policy and click “Create”

Set up credentials

  1. Navigate to the "APIs & Services“ → "Credentials” screen
  2. Click “Create Credentials” and select “OAuth Client ID”

  1. Configure the OAuth client:
  • Select “Web application” as the Application Type and give it a Name
  • In Authorized JavaScript Origins, add your site’s base URL (including https://)
  • Add your callback URL under Authorized Redirect URIs: https://your-discourse-site.com/auth/google_oauth2/callback
  • Click “Create”

Click on the OAuth 2.0 Client ID:

Copy the ClientID and Client Secret to add to your Discourse admin:

Configure Discourse settings

  1. In your Discourse admin settings under “Login & authentication”
  • Enable the setting enable google oauth2 logins
  • Enter your google oauth2 client id
  • Enter your google oauth2 client secret

Verify and publish

Test the integration by adding a user with a Google email address and confirming you can log in to Discourse using the “Log in with Google” option. If you are able to log in then the configuration is complete! :tada:

:warning: NOTE:

Previously there was one final step required - changing the Google Developer Project to production status. This no longer appears to be required. We are leaving these legacy notes here just in case.

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

Google Workspace (formally G. Suite, Google Apps) login

To restrict login to specific Google Workspace domains:

  1. In Discourse Admin -> Login & authentication, locate the google oauth2 hd site setting
  2. Enter your Google Workspace 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

Last edited by @Southpaw 2025-03-11T02:06:51Z

Check documentPerform check on document:
165 إعجابًا

للأسف، إذا اتبعت التعليمات، فإن تسجيل الدخول لا يعمل.

لكي يعمل تسجيل الدخول، اضطررت إلى إضافة كلا تنسيقي URL لإعادة التوجيه.

https://forum.example.com//auth/google_oauth2/callback http:///forum.example.comauth/google_oauth2/callback

ومع ذلك، لم أعد قادرًا على تقديم التطبيق للنشر لأن Google يتطلب عناوين بتنسيق HTTPS فقط.

أي نصائح حول كيفية حل هذا؟

أعتقد أنه ليس لديك تثبيت قياسي وتحتاج إلى تشغيل force_https.

لقد اتبعت التثبيت الرسمي. تم تمكين فرض HTTPS.

تحرير: هذا غريب، لكنه بدأ يعمل الآن! لقد جربته عشر مرات على الأقل من قبل، لكنه لم ينجح.

لا يمكنني تفسير ذلك لأن الإجراء كان هو نفسه تمامًا. ربما شيء من جانب Google؟

:person_shrugging: لا معنى له أن يتم الوصول إلى جوجل باستخدام http.

تم تقسيم مشاركة إلى موضوع جديد: Google login regression, possibly after recent changes

مرحباً، شكراً لك، لقد قمت بإعداد الإجراء اليوم وهو يعمل بشكل جيد. لقد اختبرته بحساب جوجل آخر يخصني. ومع ذلك لدي سؤال صغير، لقد حاولت التسجيل بهذا الحساب الآخر من جوجل من جهاز الكمبيوتر الخاص بي ولم أحصل إلا على خيار مفتاح الوصول. اضطررت إلى تنشيط البلوتوث للتواصل مع هاتفي. حسناً، كل ذلك لم ينجح على الإطلاق. ما أردت فعله حقاً هو النقر على زر الاتصال بجوجل ثم إكمال الإجراء ببساطة عن طريق ملء النموذج دون استخدام مفتاح وصول. أنا على جهاز الكمبيوتر الخاص بي، ليس لدي بالضرورة مفتاح وصول، ولا بصمة إصبع. ماذا أفعل إذا أردت استخدام هذا الإجراء، التسجيل بجوجل إذا لم أكن على هاتفي؟ شكراً.