Configure Google login for Discourse

Steps

  1. Go to https://console.developers.google.com, on the top left click on Select a project

  2. On the top right, click on New Project

  3. Fill in the Project Name field. You can also edit the Project ID (optional), then click on Create
    (This can take a while, so wait a minute as needed for it to appear.)

    3a. It is possible that errors are displayed after creating the project. Ignore them and refresh the page with Ctrl+F5

  4. Select your project by clicking on the project name, click on OAuth consent screen on the left panel (if you can’t find it, search using the search box at the top), select External and then click on Create

  5. Fill as appropriate; we recommend populating all these fields, then click Save.
    In the example below we use https://demo.site.com, be sure to use the URL of your Discourse site including http:// or https://. All our hosted customers have HTTPS active by default.

    :information_source: As of 2021/09/13 (September 13), Google will require you to use https.

    Noting that changing the Application logo, Google will ask to verify the site



  1. Go to the Credentials tab on the left, click on + CREATE CREDENTIALS and then click on OAuth client ID

  2. Choose Web application as the Application Type.
    In the Authorized JavaScript Origins section, add your site’s base url, including http:// or https://.
    In the Authorized Redirect URI section, add the base url with /auth/google_oauth2/callback. Click the Create button.

    :information_source: As of 2021/09/13 (September 13), Google will require you to use https.

  3. The OAuth client dialog will appear with client ID and secret.
    image

  4. (Optional) From your project, clicking on Credentials from now on you will find the OAuth credentials to edit or delete

  5. In your Discourse site settings, check enable google oauth2 logins, and fill in your google oauth2 client id and google auth2 client secret provided earlier.

  6. Your ‘project’ will have the ‘Testing’ status. Add a google user, and test that it is working.

  7. To get it fully working, you now have to change the status to In production. This means filling in a few more things, and submitting it for verification. For details see, OAuth App Verification Help Center - Google Cloud Platform Console Help

  8. You will need to confirm your ownership of the site via the Google Search Console to make Google happy. See this:

That’s it, Google login should now work on your Discourse! Go ahead and test it out with any Google account.

Tips

To enable Gsuite login enable the site setting google oauth2 hd. More info at more info here. The ID token will be validated by Discourse.

Translations

:information_source: These guides have been translated by and are maintained by the community.

Chinese (Simplified) by @honeymoose


Last Reviewed by @SaraDev on 2022-05-24T20:00:00Z

Last edited by @JammyDodger 2024-05-26T07:25:27Z

Check documentPerform check on document:
161 Likes

Unfortunately, if I follow the instructions, the login does not work.

In order to get the login to work, I had to add both URL formats for redirection.

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

However, I am now unable to submit the app for publication because Google only requires addresses in the HTTPS format.

Any advice on how to solve this?

I guess you don’t have a standard install and need to turn on force_https.

I followed the official installation. Force HTTPS is enabled.

EDIT: It’s weird, but now it’s started to work! I tried it at least ten times before, but it didn’t work.

I can’t explain it because the procedure was exactly the same. Maybe something on Google’s side?

:person_shrugging: It makes no sense that it’d be accessing google with http.