# OAuth2 Basic - Legacy replies

**URL:** https://meta.discourse.org/t/oauth2-basic-legacy-replies/90610
**Category:** SSO
**Tags:** oauth2
**Created:** [September 30, 2015, 9:07pm UTC](https://meta.discourse.org/t/oauth2-basic-legacy-replies/90610 "2015-09-30T21:07:10Z")
**Posts on this page:** 20
**Page:** 6

<div class="post-metadata">

### Author: ![trobiyo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/trobiyo/32/311872_2.png) [@trobiyo](https://meta.discourse.org/u/trobiyo)
#### Post date: [July 21, 2017, 7:55am UTC](https://meta.discourse.org/t/oauth2-basic-legacy-replies/90610/101 "2017-07-21T07:55:31Z")

</div>

Hi @zuzust ,

Did you find the way to achieve that?

---

<div class="post-metadata">

### Author: ![zuzust](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zuzust/32/120850_2.png) [@zuzust](https://meta.discourse.org/u/zuzust)
#### Post date: [July 21, 2017, 10:15am UTC](https://meta.discourse.org/t/oauth2-basic-legacy-replies/90610/102 "2017-07-21T10:15:32Z")

</div>

Hi @trobiyo, it wasn’t an easy one, too much core logic involved and no abstraction to complete the creation with a single call. `auto_create_account: true` did nothing, maybe it was a deprecated option. But I wrote some references to the code involved in my plugin: [discourse-oauth2-participa/plugin.rb at master · adab1ts/discourse-oauth2-participa · GitHub](https://github.com/adab1ts/discourse-oauth2-participa/blob/master/plugin.rb#L65). Hope it helps. Let me know if you develop that feature.

---

<div class="post-metadata">

### Author: ![kyle\_boyce](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kyle_boyce/32/75951_2.png) [@kyle\_boyce](https://meta.discourse.org/u/kyle_boyce)
#### Post date: [July 27, 2017, 8:51pm UTC](https://meta.discourse.org/t/oauth2-basic-legacy-replies/90610/103 "2017-07-27T20:51:16Z")

</div>

Did a plugin ever get made for this?

---

<div class="post-metadata">

### Author: ![featheredtoast](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/featheredtoast/32/116994_2.png) [@featheredtoast](https://meta.discourse.org/u/featheredtoast)
#### Post date: [July 27, 2017, 8:58pm UTC](https://meta.discourse.org/t/oauth2-basic-legacy-replies/90610/104 "2017-07-27T20:58:28Z")

</div>

[…Yes and it’s this?](https://meta.discourse.org/t/oauth2-basic-support/33879)

I don’t understand what you’re asking.

---

<div class="post-metadata">

### Author: ![kyle\_boyce](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kyle_boyce/32/75951_2.png) [@kyle\_boyce](https://meta.discourse.org/u/kyle_boyce)
#### Post date: [July 27, 2017, 8:59pm UTC](https://meta.discourse.org/t/oauth2-basic-legacy-replies/90610/105 "2017-07-27T20:59:16Z")

</div>

Is there a plugin I can install to have discord login to my site

---

<div class="post-metadata">

### Author: ![featheredtoast](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/featheredtoast/32/116994_2.png) [@featheredtoast](https://meta.discourse.org/u/featheredtoast)
#### Post date: [July 27, 2017, 9:00pm UTC](https://meta.discourse.org/t/oauth2-basic-legacy-replies/90610/106 "2017-07-27T21:00:10Z")

</div>

Yes - Install this plugin. Configure the plugin with the discord configuration I provided. You can now login using discord over oauth2.

---

<div class="post-metadata">

### Author: ![kyle\_boyce](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kyle_boyce/32/75951_2.png) [@kyle\_boyce](https://meta.discourse.org/u/kyle_boyce)
#### Post date: [July 27, 2017, 10:30pm UTC](https://meta.discourse.org/t/oauth2-basic-legacy-replies/90610/107 "2017-07-27T22:30:10Z")

</div>

Is everything just copy and paste or do I need to add my own stuff?

---

<div class="post-metadata">

### Author: ![featheredtoast](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/featheredtoast/32/116994_2.png) [@featheredtoast](https://meta.discourse.org/u/featheredtoast)
#### Post date: [July 31, 2017, 3:49pm UTC](https://meta.discourse.org/t/oauth2-basic-legacy-replies/90610/108 "2017-07-31T15:49:59Z")

</div>

FYI I just released a [plugin for logging in via Discord](https://meta.discourse.org/t/discord-oauth2-plugin/67174). This will require less configuration to get up and running than using the Basic Oauth2 plugin.

---

<div class="post-metadata">

### Author: ![EddEdw](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eddedw/32/87909_2.png) [@EddEdw](https://meta.discourse.org/u/EddEdw)
#### Post date: [January 12, 2018, 10:46am UTC](https://meta.discourse.org/t/oauth2-basic-legacy-replies/90610/109 "2018-01-12T10:46:30Z")

</div>

Hi guys,

I have an issue connecting to a custom oauth provider. This OAuth provider works with different applications (even RocketChat to name an OOS project). But I am having issues configuring Discourse… I figured the more educated users could have a look at my config.

The first steps of the OAuth-dance work just fine - I correctly put in the scopes in my /authorize URL (as described by @awole20 in his post [Discourse OAuth2 Basic - #104](https://meta.discourse.org/t/oauth2-basic-support/33879/104)) and I am presented our oauth provider’s HTML page to authenticate. After entering authentication data the callback url (`https://answers.intranetdomain.net/auth/oauth2_basic/callback` ← is it okay, to have `https` here even though the Github doc says `http`?) is called but after 30 seconds this runs into a 502 served by nginx in Discourse’s docker container.

My oauth2 config is (I removed the BASE\_URL for the screenshot, otherwise it would not have fit):

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

The oauth provider requires the token to be served in the auth header, therefore I exlude it from user json url (but I already tried with `?access_token=:token`).

I checked the nginx logs from within the docker container - but they don’t tell (me) anything:

```plaintext
2018/01/12 10:26:38 [error] 73#73: *1483 upstream prematurely closed connection while reading response header from upstream, client: 10.159.156.114, server: _, request: "GET /auth/oauth2_basic/callback?code=....etc.etc...", host: "https://DISCOURSE_HOST.net", referrer: "https://OAUTH_HOST.net"

```

Unfortunately also the Discourse `production.log` doesn’t explain much - following is printed to Discourse `production.log` in the moment I hit “authorize” button in the oauth provider’s login form:

```plaintext
Started GET "/auth/oauth2_basic" for 127.0.0.1 at 2018-01-12 10:26:05 +0000
(oauth2_basic) Setup endpoint detected, running now.
(oauth2_basic) Request phase initiated.
Started GET "/auth/oauth2_basic/callback?code=4613d133-56b6-.....etc.etc...." for 127.0.0.1 at 2018-01-12 10:26:08 +0000
(oauth2_basic) Setup endpoint detected, running now.
(oauth2_basic) Callback phase initiated.

```

It stops there and doesn’t continue… I tried many, many different form inputs, always the same outputs - except ofc when I don’t provide scopes → then the oauth provider rejects the request.

Is the information provided enough for the educated user to give me advice? 🙂

---

<div class="post-metadata">

### Author: ![EddEdw](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eddedw/32/87909_2.png) [@EddEdw](https://meta.discourse.org/u/EddEdw)
#### Post date: [January 12, 2018, 2:41pm UTC](https://meta.discourse.org/t/oauth2-basic-legacy-replies/90610/110 "2018-01-12T14:41:51Z")

</div>

Would this be better posted in the Support Category?

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [January 12, 2018, 2:45pm UTC](https://meta.discourse.org/t/oauth2-basic-legacy-replies/90610/111 "2018-01-12T14:45:37Z")

</div>

Can you post related discourse error log. You can see it in URL `http://discourse.example.com/logs`

---

<div class="post-metadata">

### Author: ![EddEdw](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eddedw/32/87909_2.png) [@EddEdw](https://meta.discourse.org/u/EddEdw)
#### Post date: [January 13, 2018, 1:39pm UTC](https://meta.discourse.org/t/oauth2-basic-legacy-replies/90610/112 "2018-01-13T13:39:19Z")

</div>

Hey @vinothkannans, thank you for your reply. Unfortunately there are no logs in `http://MY_DOMAIN.com/logs`. :-/ Even though I marked “Include rich debugging information in your logs” in the plugin’s settings, I find no additional log info.

My instance is running behind a proxy. I configured Discourse correctly to cope with that - from inside the running docker container can curl websites in the internet. But curl’ing the /access\_token endpoint from within the docker container fails whereas it succeeds from the VM’s shell. Could this be part of the issue? The oauth provider is only reachable within my company’s intranet, so should I add a “no\_proxy” env to be picked up by the auth module?

* * *

Update 01/13/2018: I want to add something: the SMTP server is also sitting in the intranet and Discourse has no problems reaching this resource… I also read the logs of the oauth server: the /access\_token endpoint didn’t get any request from discourse at all.

* * *

Update 01/14/2018: I also tested the Google Oauth2 plugin and it works right away, so connecting to an oauth resource in the internet is working. How can I enable Discourse to reach an internally hosted oauth2 endpoint?

---

<div class="post-metadata">

### Author: ![EddEdw](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eddedw/32/87909_2.png) [@EddEdw](https://meta.discourse.org/u/EddEdw)
#### Post date: [January 16, 2018, 4:24pm UTC](https://meta.discourse.org/t/oauth2-basic-legacy-replies/90610/113 "2018-01-16T16:24:15Z")

</div>

Hi all,

I want to give this a little bump.

The “progress” I made since my last post three days ago: setting `no_proxy` variable in the container’s `app.yml` allow curl to reach the internal oauth resource from within the container. My guess now is, that the auth module from Discourse is not picking up this variable… How can I pass a rails application environment variables, esp. a no-proxy variable? Also, how can I adjust Rail’s log level to get more entries in the `production.log` file?

---

<div class="post-metadata">

### Author: ![EddEdw](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eddedw/32/87909_2.png) [@EddEdw](https://meta.discourse.org/u/EddEdw)
#### Post date: [January 21, 2018, 9:54am UTC](https://meta.discourse.org/t/oauth2-basic-legacy-replies/90610/114 "2018-01-21T09:54:28Z")

</div>

Hi all,

I’ve found out what the problem is. Unfortunately it’s discourse’s oauth2 plugin’s inability to use `no_proxy` environment variable. I’ve found out that the responsible gem package is called Faraday [(Github link)](https://github.com/lostisland/faraday), which Discourse is using with an too-old version number where it doesn’t support `no_proxy` variable.

Okay, here my “analysis”:

**Discourse in version `v1.9.0` uses:**

```plaintext
omniauth-oauth2 (1.4.0)
      oauth2 (~> 1.0)
      omniauth (~> 1.2)

```

The package `oauth2` ([Github link tag v1.0.0](https://github.com/oauth-xx/oauth2/tree/v1.0.0)) in version `v1.0.0` uses:

```plaintext
Gem::Specification.new do |spec|
  spec.add_dependency 'faraday', ['>= 0.8', '< 0.10']

```

But the package `faraday`([Github link](https://github.com/lostisland/faraday)) got the `no_proxy` feature added in version `0.12`. The pull request adding this feature is [this one](https://github.com/lostisland/faraday/pull/658).

* * *

##### So, what could be done?

The project `oauth2` ([github link tag v1.4.0](https://github.com/oauth-xx/oauth2/tree/v1.4.0)) references the appropriate version of the `faraday` package for the first time in version `v1.4.0`:

```plaintext
Gem::Specification.new do |spec|
  spec.add_dependency 'faraday', ['>= 0.8', '< 0.13']

```

Unfortunately the package `omniauth-oauth2` ([github link tag v1.5.0](https://github.com/omniauth/omniauth-oauth2/tree/v1.5.0)) in its latest version `v1.5.0` from December 2017 only references the package `oauth2` in version `v1.1.` instead of the needed version `v1.4`:

```plaintext
Gem::Specification.new do |gem|
  gem.add_dependency "oauth2", "~> 1.1"

```

* * *

I validated that the `no_proxy` variable is the issue by setting up a small transparent squid as the target of `http_proxy` on the same machine that forwards all request to the real proxy - except requests to the oauth2-provider. These requests where not forwarded to the proxy. Aaand this works!

So, what would you guys suggest to do next?

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [January 22, 2018, 7:14pm UTC](https://meta.discourse.org/t/oauth2-basic-legacy-replies/90610/115 "2018-01-22T19:14:36Z")

</div>

> [@Discourse OAuth2 Basic](https://meta.discourse.org/t/discourse-oauth2-basic/33879/126):
>
> Unfortunately the package omniauth-oauth2 (github link tag v1.5.0) in its latest version v1.5.0 from December 2017 only references the package oauth2 in version v1.1. instead of the needed version v1.4:

I’d suggest working with the associated projects to get them to upgrade faraday so the feature is supported. Once they have a stable release we can update discourse to use them.

---

<div class="post-metadata">

### Author: ![bartv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bartv/32/130052_2.png) [@bartv](https://meta.discourse.org/u/bartv)
#### Post date: [February 5, 2018, 1:50pm UTC](https://meta.discourse.org/t/oauth2-basic-legacy-replies/90610/116 "2018-02-05T13:50:51Z")

</div>

We’re using an oAuth2 provider that has additional information in the user JSON. Is there any way I could store this in a user profile field or, even better, assign badges based on this information?

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [February 5, 2018, 2:47pm UTC](https://meta.discourse.org/t/oauth2-basic-legacy-replies/90610/117 "2018-02-05T14:47:43Z")

</div>

If you are going to store and retrieve the fields other than id, username, email then you must develop a custom plugin I think.

> [@Discourse OAuth2 Basic](https://meta.discourse.org/t/discourse-oauth2-basic/33879/128):
>
> any way I could store this in a user profile field or, even better, assign badges based on this information?

Inside a plugin you could use either way.

---

<div class="post-metadata">

### Author: ![bartv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bartv/32/130052_2.png) [@bartv](https://meta.discourse.org/u/bartv)
#### Post date: [February 5, 2018, 2:58pm UTC](https://meta.discourse.org/t/oauth2-basic-legacy-replies/90610/118 "2018-02-05T14:58:43Z")

</div>

> [@Discourse OAuth2 Basic](https://meta.discourse.org/t/discourse-oauth2-basic/33879/129):
>
> If you are going to store and retrieve the fields other than id, username, email then you must develop a custom plugin I think.

Fair enough! Could that ‘hook in’ to the existing oAuth2 plugin? I’d rather not have to fork the entire thing just to add this one feature.

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [February 5, 2018, 3:05pm UTC](https://meta.discourse.org/t/oauth2-basic-legacy-replies/90610/119 "2018-02-05T15:05:30Z")

</div>

Sure you can do. Take a look at [linkedIn oauth2 plugin](https://github.com/discourse/discourse-plugin-linkedin-auth/blob/master/plugin.rb) to understand how to use existing built-in code.

---

<div class="post-metadata">

### Author: ![mattbr](https://avatars.discourse-cdn.com/v4/letter/m/9de0a6/32.png) [@mattbr](https://meta.discourse.org/u/mattbr)
#### Post date: [February 14, 2018, 6:55pm UTC](https://meta.discourse.org/t/oauth2-basic-legacy-replies/90610/120 "2018-02-14T18:55:58Z")

</div>

I’m building OAuth2 with my own provider, I ran into a lot of issues as it required the `scope` to be set to `profile`.

I tried everything inside of the `oauth2 authorize options` for `scope=profile`, etc. Then forked the repo, added in the line:

`opts[:scope] = 'profile'`

And everything worked seemlessly. Thanks! This should definitely be added in as a site setting in the future.

[Previous page](https://meta.discourse.org/t/oauth2-basic-legacy-replies/90610.md?page=5)

[Next page](https://meta.discourse.org/t/oauth2-basic-legacy-replies/90610.md?page=7)
