# Use OAuth Plugin for Auth0 more seamlessly

**URL:** https://meta.discourse.org/t/use-oauth-plugin-for-auth0-more-seamlessly/235331
**Category:** SSO
**Created:** [August 6, 2022, 9:39pm UTC](https://meta.discourse.org/t/use-oauth-plugin-for-auth0-more-seamlessly/235331 "2022-08-06T21:39:45Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![tobi1](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobi1/32/211022_2.png) [@tobi1](https://meta.discourse.org/u/tobi1)
#### Post date: [August 6, 2022, 9:39pm UTC](https://meta.discourse.org/t/use-oauth-plugin-for-auth0-more-seamlessly/235331/1 "2022-08-06T21:39:45Z")

</div>

I am currently trying to bring Auth0 authentication to my Discourse app. I essentially followed the workflow [here](https://meta.discourse.org/t/how-to-use-auth0-with-the-oauth2-basic-plugin/64633) and I get things running.

However, I am not quite happy with it for several reasons:

1. After clicking on sign in/up, there is only a button "with Auth0’. I want there Auth0 login/sign up panel the only thing that shows up after clicking sign in/up at the top of the Discourse page.
2. After authentication with Auth0, people should not have to create a new user, instead it should all be fine because of Auth0.
3. E-mail authentication should be or should have been handled via Auth0, not via Discourse.
4. If you already have logged in via Auth0 in that browser, possibly with the same app from Auth0, in another module of our platform, then you should be automatically logged in.
5. There should still be the possibility to login as the admin user, as this might turn out to be more challenging after implementing point no. 1.

Could you help me to setup everything or at least parts of it?

---

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [August 8, 2022, 9:09am UTC](https://meta.discourse.org/t/use-oauth-plugin-for-auth0-more-seamlessly/235331/2 "2022-08-08T09:09:27Z")

</div>

> [@tobi1](#):
>
> E-mail authentication should be or should have been handled via Auth0, not via Discourse.

I believe you can check this setting in discourse `auth_overrides_email` for this.

> [@tobi1](#):
>
> After authentication with Auth0, people should not have to create a new user, instead it should all be fine because of Auth0.

And you can use this sight setting for this: `auth_skip_create_confirm`

> When signing up via external auth, skip the create account popup. Best used alongside auth\_overrides\_email, auth\_overrides\_username and auth\_overrides\_name.

There is also the `auth_immediately` setting which might do what you are after as well:

> Automatically redirect to the external login system without user interaction. This only takes effect when login\_required is true, and there is only one external authentication method

> [@tobi1](#):
>
> There should still be the possibility to login as the admin user, as this might turn out to be more challenging after implementing point no. 1.

You can visit `/u/admin-login` to bypass oauth.

---

<div class="post-metadata">

### Author: ![tobi1](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobi1/32/211022_2.png) [@tobi1](https://meta.discourse.org/u/tobi1)
#### Post date: [August 8, 2022, 2:40pm UTC](https://meta.discourse.org/t/use-oauth-plugin-for-auth0-more-seamlessly/235331/3 "2022-08-08T14:40:46Z")

</div>

Many thanks for your input, @blake 🙂

Do you also have some input for the points 1 and 4 or are these more difficult?

---

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [August 8, 2022, 5:17pm UTC](https://meta.discourse.org/t/use-oauth-plugin-for-auth0-more-seamlessly/235331/4 "2022-08-08T17:17:18Z")

</div>

I think these settings `auth_immediatley` and `auth_skip_create_confirm` will address points 1 and 4. Can you enable them and see if it improves things?

---

<div class="post-metadata">

### Author: ![tobi1](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobi1/32/211022_2.png) [@tobi1](https://meta.discourse.org/u/tobi1)
#### Post date: [August 10, 2022, 2:32pm UTC](https://meta.discourse.org/t/use-oauth-plugin-for-auth0-more-seamlessly/235331/5 "2022-08-10T14:32:30Z")

</div>

@blake Many thanks for your input.

I did everything as outlined in the setup page plus your suggestions. However, when I try to login this appears

 ![sign_in](https://global.discourse-cdn.com/meta/original/4X/1/7/b/17b4c3882f381146c1e92ada8cfa04fd7445ec5e.png)

Whereas at [https://community.auth0.com/](https://community.auth0.com/) this is what shows for trying to login (and is intended for my site as well)

 ![discourse_auth0](https://global.discourse-cdn.com/meta/original/4X/f/7/4/f745fbe68b1056384ed55c812e778c5c01106a50.png)

Furthermore, I tried to login with my test e-mail and it still requires e-mail auth despite the e-mail is authenticated at Auth0

 ![email_verification](https://global.discourse-cdn.com/meta/original/4X/5/e/f/5ef580809c0daa513cc79708beb361b12383fd61.png)

Do you know how to change it accordingly?

---

<div class="post-metadata">

### Author: ![MarkDoerr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/markdoerr/32/549630_2.png) [@MarkDoerr](https://meta.discourse.org/u/MarkDoerr)
#### Post date: [December 16, 2022, 6:45pm UTC](https://meta.discourse.org/t/use-oauth-plugin-for-auth0-more-seamlessly/235331/6 "2022-12-16T18:45:00Z")

</div>

Try disabling the `enable local logins` settings. This should remove the ability to login leaving your users only the option of logging in with OAuth2.

I would recommend doing this this in a separate browser session though. That way you can revert any changes you make if you have configuration problems without losing the ability to login.

---

<div class="post-metadata">

### Author: ![robertkibet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/robertkibet/32/290055_2.png) [@robertkibet](https://meta.discourse.org/u/robertkibet)
#### Post date: [January 20, 2023, 9:45am UTC](https://meta.discourse.org/t/use-oauth-plugin-for-auth0-more-seamlessly/235331/7 "2023-01-20T09:45:30Z")

</div>

Hello @blake  
Thanks for the insights. I have made some progress but unfortunately there is still a slight problem with login. Whenever I hit the login button, correct information for the user is fetched from auth0, but discourse still tries to create an account.  
I am taken to a _Welcome, lets create your account_ screen with an error that says **Primary email has already been taken** error.

This is my current config for all the overrides:

 ![Capture](https://global.discourse-cdn.com/meta/original/4X/e/8/3/e8340843cdeb4f92938b58ed252cd74c465c9a9f.png)

Kindly assist, thanks.

---

<div class="post-metadata">

### Author: ![leonardo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leonardo/32/228634_2.png) [@leonardo](https://meta.discourse.org/u/leonardo)
#### Post date: [January 20, 2023, 1:22pm UTC](https://meta.discourse.org/t/use-oauth-plugin-for-auth0-more-seamlessly/235331/8 "2023-01-20T13:22:51Z")

</div>

Hi Robert!

You can fix this by enabling this setting: `oauth2 allow association change`

---

<div class="post-metadata">

### Author: ![robertkibet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/robertkibet/32/290055_2.png) [@robertkibet](https://meta.discourse.org/u/robertkibet)
#### Post date: [January 20, 2023, 1:49pm UTC](https://meta.discourse.org/t/use-oauth-plugin-for-auth0-more-seamlessly/235331/9 "2023-01-20T13:49:34Z")

</div>

Hello @leonardo unfortunately the issue still persists after enabling that setting.

---

<div class="post-metadata">

### Author: ![robertkibet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/robertkibet/32/290055_2.png) [@robertkibet](https://meta.discourse.org/u/robertkibet)
#### Post date: [January 20, 2023, 2:24pm UTC](https://meta.discourse.org/t/use-oauth-plugin-for-auth0-more-seamlessly/235331/10 "2023-01-20T14:24:30Z")

</div>

> [@blake](#):
>
> auth\_overrides\_email

somehow it is working well now. I added **oauth2**  **email verified** rule and its now working. Interesting.

---

<div class="post-metadata">

### Author: ![gagegreg](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gagegreg/32/472520_2.png) [@gagegreg](https://meta.discourse.org/u/gagegreg)
#### Post date: [December 11, 2024, 9:48pm UTC](https://meta.discourse.org/t/use-oauth-plugin-for-auth0-more-seamlessly/235331/11 "2024-12-11T21:48:07Z")

</div>

Love this plugin. I notice when I sign out, it does sign me out out Discourse. But when I click sign in… it immediately signs me back in (without going to Auth0). I allowed the logout URI in my Auth0 App, but it looks like https://AUTH0\_DOMAIN/v2/logout never gets called from this plugin. Who maintains this? Can this be added?
