# Switching from GitHub auth to OAuth2

**URL:** <https://meta.discourse.org/t/switching-from-github-auth-to-oauth2/111218>\
**Category:** SSO\
**Tags:** oauth2\
**Created:** [March 10, 2019, 6:05pm UTC](https://meta.discourse.org/t/switching-from-github-auth-to-oauth2/111218 "2019-03-10T18:05:21Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![cori](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cori/32/124112_2.png) [@cori](https://meta.discourse.org/u/cori)\
**Post date:** [March 10, 2019, 6:05pm UTC](https://meta.discourse.org/t/switching-from-github-auth-to-oauth2/111218/1 "2019-03-10T18:05:21Z")

</div>

Hey folks, we’re running hosted Discourse using only GitHub authentication. We’ve successfully added functionality to our own platform to delegate authentication to our system using OAuth2, and our goal is to switch from GitHub auth to OAuth2, and hoped that users logging in using OAuth2 with the same email address that’s associated with an existing account would be logged _into_ that account.

My testing in a self-hosted Discourse so far goes like this. I’ve got a few accounts with the same email address in both GitHub and in our external system:

1. I create an account in our test instance using GitHub authentication.
2. sign out of that account in the test instance
3. attempt to log in using OAuth2 and an account in our system with the same email address

For these accounts when I perform step 3 I’m prompted to create a new account instead of being logged into the existing account, and if I try to complete that process I’m told the email already exists (as one would expect). Here’s a screenshot of _one_ account combination:

 ![image](https://global.discourse-cdn.com/meta/original/3X/c/f/cf13a6faa277c8551056c9236948f26bee465d52.png)

The login attempt is on the right; on the left is the admin view of the corresponding account.

Oddly, with another account (the initial admin account) I can log in using GitHub or OAuth2 interchangeably without any difficulty.

What are the correct expectations for this functionality? Should these accounts be recognized as the same? Is there somewhere in the database that I can look to see why some accounts work as hoped and others do not? Is there a mechanism or configuration that I’m missing that will make this work as hoped? Any guidance appreciated!

---

_[View the full topic](https://meta.discourse.org/t/switching-from-github-auth-to-oauth2/111218)._
