Configuring Google OAuth2 login for plugins

Here’s how to configure Google Console to allow login and registration with Google OAuth2. You’ll need this for both:

(h/t Configure Google login for Discourse - admins - Discourse Meta)

  1. Go to https://console.developers.google.com and create a new Project. When you submit the new project, you’ll see a page that still says that you have no projects. Just wait for about a minute and the project will appear.


  2. In the new project, in the menu on the left, click “APIs & auth” > Credentials. Click the “Create New Client ID” button on the right side.

  3. 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 Client ID button.

  4. After some time, the web application will appear with its client ID and secret.

  5. Under “APIs & auth” > APIs, you’ll see a huge list. Find “Contacts API” and “Google+ API”. Enable both of them.

  1. In the “APIs & auth” > “Consent screen” section, edit the product name.

  2. In your plugin settings, fill in your client id and client secret from step 4.

HTTPS

If you’re using SSL and are getting errors when authenticating with Google OAuth2, see this topic.