# Possible oauth2 problem with Discourse and Auth0 EU sites

**URL:** <https://community.auth0.com/t/possible-oauth2-problem-with-discourse-and-auth0-eu-sites/13681>\
**Category:** Get Help\
**Created:** [July 26, 2018, 4:20pm UTC](https://community.auth0.com/t/possible-oauth2-problem-with-discourse-and-auth0-eu-sites/13681 "2018-07-26T16:20:19Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![oblakeerickson](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/oblakeerickson/32/8270_2.png) [@oblakeerickson](https://community.auth0.com/u/oblakeerickson)\
**Post date:** [July 26, 2018, 4:20pm UTC](https://community.auth0.com/t/possible-oauth2-problem-with-discourse-and-auth0-eu-sites/13681/1 "2018-07-26T16:20:20Z")

</div>

Hi Auth0 Team, I’m a developer for Discourse and the author of this how-to guide:

> **[Configure sign up and log in with Auth0 using the OAuth2 Basic Plugin](https://meta.discourse.org/t/configure-sign-up-and-log-in-with-auth0-using-the-oauth2-basic-plugin/64633)**
>
> If you are using Auth0 as your identity provider this guide will show you how to setup authentication using the Discourse OAuth2 Basic Plugin. Initial Steps Create an Auth0 account if you don’t already have one The Discourse OAuth2 Basic Plugin...

We currently have two Discourse users both using EU Auth0 accounts that are experiencing the exact same issue and I can replicate it with my own EU Auth0 account that I just set up.

I have two test discourse forums setup attached to two separate auth0 accounts:

[https://discourse-test-prod-box.blakeerickson.com/](https://discourse-test-prod-box.blakeerickson.com/) (`[tenant].auth0.com`) [working]  
[https://auth0.blakeerickson.com](https://auth0.blakeerickson.com) (`[tenant].eu.auth0.com`) [not-working]

They are setup identically, and I’ve tried lots of different settings for the eu one trying to get a different result with no luck. The problem is that the EU site doesn’t return a populated user\_json:

 ![image](https://global.discourse-cdn.com/auth0/original/2X/a/af2e36ce774dee3c40d1a418e21ebfc752a2668c.png)

Compare that to the user\_json from the US based Auth0 site:

 ![image](https://global.discourse-cdn.com/auth0/original/2X/1/1cd1f61fa7a686af0704a496ff085148ae90372f.png)

```plaintext
OAuth2Debugging: user_json: {
	"email_verified"=>false,
	"email"=>" *********",
	"clientID"=>" ********",
	"updated_at"=>"2018-07-26T15:59:20.670Z",
	"name"=>" *******",
	"picture"=>"https://s.gravatar.com/avatar/c5ede5ffce493dbf25578f348f856c26?s=480&r=pg&d=https%3A%2F%2Fcdn.auth0.com%2Favatars%2Fbl.png",
	"user_id"=>"auth0| ******",
	"nickname"=>" ******",
	"identities"=>[{
		"user_id"=>" ******",
		"provider"=>"auth0",
		"connection"=>"Username-Password-Authentication",
		"isSocial"=>false
	}],
	"created_at"=>"2018-07-26T15:59:20.338Z",
	"sub"=>" *******"
}

```

I guess I’m kind of stuck debugging this on my own and if you could provide any help or assistance that would be great!

---

<div class="post-metadata">

**Author:** ![RCheesley](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rcheesley/32/12343_2.png) [@RCheesley](https://community.auth0.com/u/RCheesley)\
**Post date:** [July 26, 2018, 5:09pm UTC](https://community.auth0.com/t/possible-oauth2-problem-with-discourse-and-auth0-eu-sites/13681/2 "2018-07-26T17:09:04Z")

</div>

My open ticket is #44440 for reference - with this problem. My tenant is, however, US based.

---

<div class="post-metadata">

**Author:** ![jerdog](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jerdog/32/11231_2.png) [@jerdog](https://community.auth0.com/u/jerdog)\
**Post date:** [July 26, 2018, 5:39pm UTC](https://community.auth0.com/t/possible-oauth2-problem-with-discourse-and-auth0-eu-sites/13681/3 "2018-07-26T17:39:44Z")

</div>

Can you provide the settings in Discourse for your oauth2 plugin? A PM is fine. Make sure to comment out all private info unless you’re sending a PM

Specifically:

 ![image](https://global.discourse-cdn.com/auth0/original/2X/7/7f239d6f0a3833d701e57b677ed6432479071c4c.png)

---

<div class="post-metadata">

**Author:** ![sergiocintra](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@sergiocintra](https://community.auth0.com/u/sergiocintra)\
**Post date:** [July 26, 2018, 6:15pm UTC](https://community.auth0.com/t/possible-oauth2-problem-with-discourse-and-auth0-eu-sites/13681/4 "2018-07-26T18:15:52Z")

</div>

I am with the same problem. I tried with two tenants: EU and US based.

---

<div class="post-metadata">

**Author:** ![oblakeerickson](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/oblakeerickson/32/8270_2.png) [@oblakeerickson](https://community.auth0.com/u/oblakeerickson)\
**Post date:** [July 26, 2018, 7:23pm UTC](https://community.auth0.com/t/possible-oauth2-problem-with-discourse-and-auth0-eu-sites/13681/6 "2018-07-26T19:23:29Z")

</div>

Not working site:

 ![image](https://global.discourse-cdn.com/auth0/original/2X/b/b158bb6d0e970ceb0c068e29ea8d9bc34dcf3525.png)

Working site:

 ![image](https://global.discourse-cdn.com/auth0/original/2X/2/268e0ba75a59cef31f92a38611c3ab6e9602193c.png)

If it makes any difference my working Auth0 account I have had for a long time, my EU based Auth0 account is new today.

---

<div class="post-metadata">

**Author:** ![jerdog](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jerdog/32/11231_2.png) [@jerdog](https://community.auth0.com/u/jerdog)\
**Post date:** [July 27, 2018, 4:15pm UTC](https://community.auth0.com/t/possible-oauth2-problem-with-discourse-and-auth0-eu-sites/13681/7 "2018-07-27T16:15:11Z")

</div>

So here are some things to look at, mimicking the settings that we use on this site:

**oauth2 authorize url** : `https://[tenant].auth0.com/authorize?scope=openid%20profile%20email`  
**oauth2 token url** : `https://[tenant].auth0.com/oauth/token`  
**oauth2 user json url** : `https://[tenant].auth0.com/userinfo`  
**oauth2 json user id path** : `sub`  
**oauth2 json username path** : `nickname`  
**oauth2 json name path** : `name`  
**oauth2 json email path** : `email`  
**oauth2 send auth header** : ✔ Send the token as an HTTP Authorization header

With nothing in `oauth2 scope`

Also, please make sure your tenant logs don’t have any deprecation warnings

---

<div class="post-metadata">

**Author:** ![oblakeerickson](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/oblakeerickson/32/8270_2.png) [@oblakeerickson](https://community.auth0.com/u/oblakeerickson)\
**Post date:** [July 27, 2018, 8:51pm UTC](https://community.auth0.com/t/possible-oauth2-problem-with-discourse-and-auth0-eu-sites/13681/8 "2018-07-27T20:51:41Z")

</div>

Okay, I’ll try these out when I get a chance.

---

<div class="post-metadata">

**Author:** ![oblakeerickson](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/oblakeerickson/32/8270_2.png) [@oblakeerickson](https://community.auth0.com/u/oblakeerickson)\
**Post date:** [July 28, 2018, 4:48am UTC](https://community.auth0.com/t/possible-oauth2-problem-with-discourse-and-auth0-eu-sites/13681/9 "2018-07-28T04:48:29Z")

</div>

Awesome, thank you!

The key fix was the scope needs to be passed to the authorize url value (I also updated all my oauth2 json values to match what you have above once I was getting a json result back from Auth0).

> [@jerdog](#):
>
> **oauth2 authorize url** : `https://[tenant].auth0.com/authorize?scope=openid%20profile%20email`

Rather than adding the scope directly to the URL though, there actually is somewhat recent addition to the discourse oauth2 basic plugin that [adds a scope field to the site settings](https://meta.discourse.org/t/support-for-specifying-a-custom-scope/90603), so that you can have these settings:

**oauth2 authorize url** : `https://[tenant].auth0.com/authorize`  
**oauth2 authorize options** : `scope`  
**oauth2 scope** : `openid profile email`

Sorry for the trouble here, my old Auth0 account still works without adding the scope fields to the auth url, but my new Auth0 account (and everyone elses!) needs them. Looks like this is in the [auth0 oauth2 docs](https://auth0.com/docs/protocols/oauth2#how-response-type-works), so I probably should have read them!

> scope: A space-delimited list of permissions that the application requires.

[Standard claim docs](https://auth0.com/docs/scopes/current#example-ask-for-standard-claims):

> Notice that we included three values at the scope param: openid, profile (to get name, nickname and picture) and email (to get the email claim).

---

<div class="post-metadata">

**Author:** ![RCheesley](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rcheesley/32/12343_2.png) [@RCheesley](https://community.auth0.com/u/RCheesley)\
**Post date:** [July 30, 2018, 5:17pm UTC](https://community.auth0.com/t/possible-oauth2-problem-with-discourse-and-auth0-eu-sites/13681/10 "2018-07-30T17:17:31Z")

</div>

I can confirm that following the updated docs on the Discourse thread results in Auth0 working and the required data being populated! Hurrah, thanks so much everybody for helping us get to the bottom of this!

Ruth

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [December 17, 2018, 10:39am UTC](https://community.auth0.com/t/possible-oauth2-problem-with-discourse-and-auth0-eu-sites/13681/11 "2018-12-17T10:39:25Z")

</div>


