# Problems with oauth2-basic-support

**URL:** https://meta.discourse.org/t/problems-with-oauth2-basic-support/188520
**Category:** SSO
**Created:** [April 29, 2021, 10:00am UTC](https://meta.discourse.org/t/problems-with-oauth2-basic-support/188520 "2021-04-29T10:00:13Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![wayyt\_cc3090](https://avatars.discourse-cdn.com/v4/letter/w/aca169/32.png) [@wayyt\_cc3090](https://meta.discourse.org/u/wayyt_cc3090)
#### Post date: [April 29, 2021, 10:00am UTC](https://meta.discourse.org/t/problems-with-oauth2-basic-support/188520/1 "2021-04-29T10:00:13Z")

</div>

## **This is my configuration**

 ![image](https://global.discourse-cdn.com/meta/original/3X/4/6/46caa0749d963834e9949b8d8dcb71778ea9bb03.png)

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

## In logs， obviously，I got my access\_token successful。 but something went wrong。

 ![image](https://global.discourse-cdn.com/meta/original/3X/1/3/135c6de9f2ebe26e72e3071ac2fd5c24a4920441.png)

 ![image](https://global.discourse-cdn.com/meta/original/3X/9/4/9440ca8b9a52737cad11d610e243326fca01aa9e.png)

## here is error info

```plaintext
(oauth2_basic) Authentication failure! invalid_credentials: OAuth2::Error, {"access_token":"44_CpvhnU0R8E6oVB8tDNZBNNXvGCkoY0RAfRJByMLhvt1pUEeyrnqmis4hj8qsQUC7o_9e8-TyySN9ZpEPWyli1y_sSqTwOxoEfglBtFcW0Qw","expires_in":7200,"refresh_token":"44_am-wOd7TZ49pDls4C2LSwmXmHfT6-vawS7aWSfHi2Z316gV_o5cwvX-NJX8SIx-i65wWquRZa2qabnx1ZLlkUBdbAm-bntFgIW-wWiNXhZs","openid":"obhpt6YmqjmBw643L41kJkncc-60","scope":"snsapi_userinfo"}

```

## here is backtrace

```plaintext
omniauth-1.9.1/lib/omniauth/strategy.rb:163:in `log'
omniauth-1.9.1/lib/omniauth/strategy.rb:486:in `fail!'
omniauth-oauth2-1.7.1/lib/omniauth/strategies/oauth2.rb:96:in `rescue in callback_phase'
omniauth-oauth2-1.7.1/lib/omniauth/strategies/oauth2.rb:84:in `callback_phase'
omniauth-1.9.1/lib/omniauth/strategy.rb:238:in `callback_call'
omniauth-1.9.1/lib/omniauth/strategy.rb:189:in `call!'
omniauth-1.9.1/lib/omniauth/strategy.rb:169:in `call'
omniauth-1.9.1/lib/omniauth/strategy.rb:192:in `call!'
omniauth-1.9.1/lib/omniauth/strategy.rb:169:in `call'
omniauth-1.9.1/lib/omniauth/strategy.rb:192:in `call!'
omniauth-1.9.1/lib/omniauth/strategy.rb:169:in `call'
omniauth-1.9.1/lib/omniauth/strategy.rb:192:in `call!'
omniauth-1.9.1/lib/omniauth/strategy.rb:169:in `call'
omniauth-1.9.1/lib/omniauth/strategy.rb:192:in `call!'
omniauth-1.9.1/lib/omniauth/strategy.rb:169:in `call'
omniauth-1.9.1/lib/omniauth/strategy.rb:192:in `call!'
omniauth-1.9.1/lib/omniauth/strategy.rb:169:in `call'
omniauth-1.9.1/lib/omniauth/builder.rb:45:in `call'
/var/www/discourse/lib/middleware/omniauth_bypass_middleware.rb:50:in `call'
rack-2.2.3/lib/rack/tempfile_reaper.rb:15:in `call'
rack-2.2.3/lib/rack/conditional_get.rb:27:in `call'
rack-2.2.3/lib/rack/head.rb:12:in `call'
actionpack-6.1.3.1/lib/action_dispatch/http/permissions_policy.rb:22:in `call'
/var/www/discourse/lib/content_security_policy/middleware.rb:12:in `call'
/var/www/discourse/lib/middleware/anonymous_cache.rb:353:in `call'
rack-2.2.3/lib/rack/session/abstract/id.rb:266:in `context'
rack-2.2.3/lib/rack/session/abstract/id.rb:260:in `call'
actionpack-6.1.3.1/lib/action_dispatch/middleware/cookies.rb:689:in `call'
actionpack-6.1.3.1/lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport-6.1.3.1/lib/active_support/callbacks.rb:98:in `run_callbacks'
actionpack-6.1.3.1/lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack-6.1.3.1/lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
actionpack-6.1.3.1/lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call'
actionpack-6.1.3.1/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
logster-2.9.6/lib/logster/middleware/reporter.rb:43:in `call'
railties-6.1.3.1/lib/rails/rack/logger.rb:37:in `call_app'
railties-6.1.3.1/lib/rails/rack/logger.rb:28:in `call'
/var/www/discourse/config/initializers/100-quiet_logger.rb:23:in `call'
/var/www/discourse/config/initializers/100-silence_logger.rb:31:in `call'
actionpack-6.1.3.1/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack-6.1.3.1/lib/action_dispatch/middleware/request_id.rb:26:in `call'
/var/www/discourse/lib/middleware/enforce_hostname.rb:23:in `call'
rack-2.2.3/lib/rack/method_override.rb:24:in `call'
actionpack-6.1.3.1/lib/action_dispatch/middleware/executor.rb:14:in `call'
rack-2.2.3/lib/rack/sendfile.rb:110:in `call'
actionpack-6.1.3.1/lib/action_dispatch/middleware/host_authorization.rb:92:in `call'
rack-mini-profiler-2.3.1/lib/mini_profiler/profiler.rb:248:in `call'
message_bus-3.3.4/lib/message_bus/rack/middleware.rb:61:in `call'
/var/www/discourse/lib/middleware/request_tracker.rb:177:in `call'
railties-6.1.3.1/lib/rails/engine.rb:539:in `call'
railties-6.1.3.1/lib/rails/railtie.rb:207:in `public_send'
railties-6.1.3.1/lib/rails/railtie.rb:207:in `method_missing'
rack-2.2.3/lib/rack/urlmap.rb:74:in `block in call'
rack-2.2.3/lib/rack/urlmap.rb:58:in `each'
rack-2.2.3/lib/rack/urlmap.rb:58:in `call'
unicorn-6.0.0/lib/unicorn/http_server.rb:634:in `process_client'
unicorn-6.0.0/lib/unicorn/http_server.rb:732:in `worker_loop'
unicorn-6.0.0/lib/unicorn/http_server.rb:547:in `spawn_missing_workers'
unicorn-6.0.0/lib/unicorn/http_server.rb:143:in `start'
unicorn-6.0.0/bin/unicorn:128:in `<top (required)>'
/var/www/discourse/vendor/bundle/ruby/2.7.0/bin/unicorn:23:in `load'
/var/www/discourse/vendor/bundle/ruby/2.7.0/bin/unicorn:23:in `<main>'

```

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [April 29, 2021, 12:44pm UTC](https://meta.discourse.org/t/problems-with-oauth2-basic-support/188520/2 "2021-04-29T12:44:10Z")

</div>

It might mean they the oauth server isn’t allowing access to everything it needs. I’d it sending an email address?

---

<div class="post-metadata">

### Author: ![wayyt\_cc3090](https://avatars.discourse-cdn.com/v4/letter/w/aca169/32.png) [@wayyt\_cc3090](https://meta.discourse.org/u/wayyt_cc3090)
#### Post date: [April 29, 2021, 3:59pm UTC](https://meta.discourse.org/t/problems-with-oauth2-basic-support/188520/3 "2021-04-29T15:59:10Z")

</div>

but the error message seems sent by discourse。 not the call back server。

> [@pfaffman](#):
>
> I’d it sending an email address?

what’s that means？

---

<div class="post-metadata">

### Author: ![wayyt\_cc3090](https://avatars.discourse-cdn.com/v4/letter/w/aca169/32.png) [@wayyt\_cc3090](https://meta.discourse.org/u/wayyt_cc3090)
#### Post date: [April 30, 2021, 5:48am UTC](https://meta.discourse.org/t/problems-with-oauth2-basic-support/188520/4 "2021-04-30T05:48:59Z")

</div>

Hey Bro, I already solve my issue. But I got new trouble.  
When I use Oauth2 login, If I already have a account , I want to connect them by email. What should I do?

---

<div class="post-metadata">

### Author: ![wayyt\_cc3090](https://avatars.discourse-cdn.com/v4/letter/w/aca169/32.png) [@wayyt\_cc3090](https://meta.discourse.org/u/wayyt_cc3090)
#### Post date: [April 30, 2021, 5:53am UTC](https://meta.discourse.org/t/problems-with-oauth2-basic-support/188520/5 "2021-04-30T05:53:39Z")

</div>

![image](https://global.discourse-cdn.com/meta/original/3X/b/e/becb2aea464ad29190d44cd4e4cddc70ab039a5f.png)  
like this I don’t want to get error message “Email has already token”。 I want them connect

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [April 30, 2021, 12:20pm UTC](https://meta.discourse.org/t/problems-with-oauth2-basic-support/188520/6 "2021-04-30T12:20:04Z")

</div>

You should just login, not create an account.

---

<div class="post-metadata">

### Author: ![wayyt\_cc3090](https://avatars.discourse-cdn.com/v4/letter/w/aca169/32.png) [@wayyt\_cc3090](https://meta.discourse.org/u/wayyt_cc3090)
#### Post date: [April 30, 2021, 1:01pm UTC](https://meta.discourse.org/t/problems-with-oauth2-basic-support/188520/7 "2021-04-30T13:01:20Z")

</div>

Because my oauth2 server didn’t have email field . So When I used oauth2 login，discourse want’s me input email and verify.

When I log in with oauth2 and enter an email, if my oauth2 server does not have an email field, how to realize that the email should be re-authenticated and overwrite the registered account, just like the github

---

<div class="post-metadata">

### Author: ![qinyj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/qinyj/32/204391_2.png) [@qinyj](https://meta.discourse.org/u/qinyj)
#### Post date: [August 18, 2022, 6:01pm UTC](https://meta.discourse.org/t/problems-with-oauth2-basic-support/188520/9 "2022-08-18T18:01:16Z")

</div>

how you solved that? i met the same problem when i trying to use wechat oauth

---

<div class="post-metadata">

### Author: ![rsegura](https://avatars.discourse-cdn.com/v4/letter/r/f6c823/32.png) [@rsegura](https://meta.discourse.org/u/rsegura)
#### Post date: [June 16, 2023, 10:49am UTC](https://meta.discourse.org/t/problems-with-oauth2-basic-support/188520/10 "2023-06-16T10:49:17Z")

</div>

@wayyt_cc3090 Hi!.. How do you solved the “Authentication failure!” error?

Thanks!
