Configuring Google login for Discourse

Steps

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

  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 clicking on the project name, click on OAuth consent screen on the left panel, 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


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

  7. 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.

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

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

  10. 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.

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

  12. 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 API verification FAQs - Google Cloud Platform Console Help

  13. 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 @AlexDev on 2022-05-24T20:00:00Z

153 Likes