Problems with oauth2-basic-support

This is my configuration

In logs, obviously,I got my access_token successful。 but something went wrong。

here is error info

(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

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>'


1 Like

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

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

what’s that means?

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?


like this I don’t want to get error message “Email has already token”。 I want them connect

1 Like

You should just login, not create an account.

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

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

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

Thanks!