# Oauth2 with GitHub howto

**URL:** https://meta.discourse.org/t/oauth2-with-github-howto/358125
**Category:** Extras
**Tags:** github, oauth2
**Created:** [March 20, 2025, 10:45am UTC](https://meta.discourse.org/t/oauth2-with-github-howto/358125 "2025-03-20T10:45:13Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![rommelfs](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rommelfs/32/494943_2.png) [@rommelfs](https://meta.discourse.org/u/rommelfs)
#### Post date: [March 20, 2025, 10:45am UTC](https://meta.discourse.org/t/oauth2-with-github-howto/358125/1 "2025-03-20T10:45:13Z")

</div>

For all those people having issues to get oauth2 to work with GitHub, here’s a solution.

Problem: Discourse oauth2 plugin generates a 500 error when enabled with Github and the fields in configuration are not correctly set. As documentation is spare about what and how to configure, here are the important (and some optional) fields:

`OAuth2 client ID` Client ID from GitHub  
`OAuth2 client secret` Client Secret from GitHub  
`OAuth2 authorize URL` https[:]//github[.]com/login/oauth/authorize  
`OAuth2 token URL` https[:]//github[.]com/login/oauth/access\_token  
`OAuth2 token URL method` POST  
`OAuth2 user JSON URL` https[:][//api.github](https://api.github)[.]com/user  
`OAuth2 user JSON URL method` GET  
`OAuth2 JSON user ID path` id  
`OAuth2 JSON username path` login  
`OAuth2 JSON name path` name  
`OAuth2 JSON email path` mail  
`OAuth2 JSON avatar path` avatar\_url  
`OAuth2 send auth header` x  
`OAuth2 send auth body` x  
`OAuth2 allow association change` x

for debugging (only):  
`OAuth2 debug auth` x

On GitHub side, in case you’re missing this information as well, here’s what is needed:  
Go to https[:]//github[.]com/settings/developers, click on “New OAuth App”  
Enter Application Name (e.g. Discourse),  
Homepage URL  
and  
Authorization callback URL (https[:][//YOUR.DISCOURSESERV](https://YOUR.DISCOURSESERV)[.]ER/auth/oauth2\_basic/callback)  
and don’t forget to click on Update application.

That’s it.  
Hope that helps!

Can I ask the developers to please check the (invalid because empty) return when the mandatory “OAuth2 user JSON URL” is not set? It generates this error and throws a 500.

ActiveRecord::NotNullViolation (PG::NotNullViolation: ERROR: null value in column “provider\_uid” of relation “user\_associated\_accounts” violates not-null constraint

Sorry for the obfuscation in the URLs, I have been told that new users can only have 2 links per post.

---

<div class="post-metadata">

### Author: ![vijayan\_mmm](https://avatars.discourse-cdn.com/v4/letter/v/71e660/32.png) [@vijayan\_mmm](https://meta.discourse.org/u/vijayan_mmm)
#### Post date: [April 27, 2026, 12:32pm UTC](https://meta.discourse.org/t/oauth2-with-github-howto/358125/2 "2026-04-27T12:32:20Z")

</div>

Today i also faced this issue, The error disappeared after i set the correct value for the the “OAuth2 callback user ID path” .

![image](https://global.discourse-cdn.com/meta/optimized/4X/1/a/9/1a9c9f0fcc3956f6ecde9e97bf58563b503d0683_2_690x75.png)

"
