# Discourse SSO with OAuth2

**URL:** https://meta.discourse.org/t/discourse-sso-with-oauth2/132384
**Category:** Support
**Created:** [November 1, 2019, 10:36am UTC](https://meta.discourse.org/t/discourse-sso-with-oauth2/132384 "2019-11-01T10:36:58Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![arivanandan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arivanandan/32/160108_2.png) [@arivanandan](https://meta.discourse.org/u/arivanandan)
#### Post date: [November 1, 2019, 10:36am UTC](https://meta.discourse.org/t/discourse-sso-with-oauth2/132384/1 "2019-11-01T10:36:58Z")

</div>

I’d like to set up SSO with github OAuth. When the user logs in to my site via github, it should also sign them in to discourse. Discourse comments are embedded on the site.

How do I go about this?

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [November 1, 2019, 10:50am UTC](https://meta.discourse.org/t/discourse-sso-with-oauth2/132384/2 "2019-11-01T10:50:01Z")

</div>

For OAuth2 connection to your own site, you could use this plugin

> [@Discourse OAuth2 Basic](https://meta.discourse.org/t/oauth2-basic-support/33879):
>
> discourse2Summary Discourse OAuth2 Basic supports basic OAuth2 providers, assuming they have a JSON API endpoint where user details can be retrieved by token.open_bookInstall Guide This plugin is bundled with Discourse core. There is no need to install the plugin separately. Features This plugin allows you to use a basic OAuth2 provider as authentication for Discourse. It should work with many providers, with the caveat that they must provide a JSON endpoint for retri…

“Login with GitHub” is built-in to discourse, and you can find setup instructions here:

> [@Configure GitHub login for Discourse](https://meta.discourse.org/t/configuring-github-login-for-discourse/13745):
>
> bookmark This guide explains how to set up GitHub as a login option for your Discourse forum by configuring OAuth credentials. person_raising_hand Required user level: Administrator Overview GitHub login integration allows users to sign in to your Discourse site using their GitHub accounts. This provides a convenient authentication option, especially useful for developer-focused communities. Setting up GitHub OAuth Visit GitHub’s developer settings at https://github.com/settings/dev…

---

<div class="post-metadata">

### Author: ![arivanandan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arivanandan/32/160108_2.png) [@arivanandan](https://meta.discourse.org/u/arivanandan)
#### Post date: [November 2, 2019, 9:08pm UTC](https://meta.discourse.org/t/discourse-sso-with-oauth2/132384/3 "2019-11-02T21:08:18Z")

</div>

I’m still confused.

In case it wasn’t clear, I have

> Website with Github OAuth.  
> Discourse with Github OAuth.

Neither of them have any other login methods.  
When a user logs in to my website, they should be logged into discourse as well.

What I’m missing is the link between them. How do I log them into discourse when they authenticate via Github OAuth on my website?

---

<div class="post-metadata">

### Author: ![itsbhanusharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/itsbhanusharma/32/180717_2.png) [@itsbhanusharma](https://meta.discourse.org/u/itsbhanusharma)
#### Post date: [November 2, 2019, 9:24pm UTC](https://meta.discourse.org/t/discourse-sso-with-oauth2/132384/4 "2019-11-02T21:24:16Z")

</div>

When someone logs into Your website, the only talking that happens is in between GitHub and your website.

I.e.  
Your website calls github to ask if a user exists in their user database  
Github responds yes (or no) and returns user data or authentication token as requested by your site.  
Now, the user gets logged in to your site.

There is no play of discourse here in the equation. What you need here is some way to tell discourse that the given user has just logged in and needs to be logged into discourse as well.

What You need is a way to enqueue discourse login along with your website login so that discourse knows when a user has logged in/out.

Auth0 does this pretty well out of the box..  
Another way is to use discourse as your SSO server.

---

<div class="post-metadata">

### Author: ![arivanandan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arivanandan/32/160108_2.png) [@arivanandan](https://meta.discourse.org/u/arivanandan)
#### Post date: [November 3, 2019, 1:46pm UTC](https://meta.discourse.org/t/discourse-sso-with-oauth2/132384/5 "2019-11-03T13:46:33Z")

</div>

Thanks for the replies!

I figured the auth plugin I use actually runs though OAuth and gives a JWT. The [discourse-jwt](https://github.com/discourse/discourse-jwt) thing should work for me I think.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [December 3, 2019, 2:00pm UTC](https://meta.discourse.org/t/discourse-sso-with-oauth2/132384/6 "2019-12-03T14:00:55Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
