Erreur OAuth - Impossible de connaître la cause exacte de cette erreur

We get this this OAuth error and refreshing the page it works…I did check the error log and here is the details:::

Faraday::TimeoutError (Timeout::Error)

I get this below traceback log error:

activesupport-7.2.2/lib/active_support/broadcast_logger.rb:130:in `block in warn'
activesupport-7.2.2/lib/active_support/broadcast_logger.rb:231:in `block in dispatch'
activesupport-7.2.2/lib/active_support/broadcast_logger.rb:231:in `each'
activesupport-7.2.2/lib/active_support/broadcast_logger.rb:231:in `dispatch'
activesupport-7.2.2/lib/active_support/broadcast_logger.rb:130:in `warn'
/usr/local/lib/ruby/3.3.0/forwardable.rb:240:in `warn'
/var/www/discourse/plugins/discourse-oauth2-basic/lib/oauth2_faraday_formatter.rb:7:in `request'
faraday-2.12.1/lib/faraday/response/logger.rb:22:in `call'
faraday-2.12.1/lib/faraday/rack_builder.rb:152:in `build_response'
faraday-2.12.1/lib/faraday/connection.rb:452:in `run_request'
oauth2-1.4.11/lib/oauth2/client.rb:107:in `request'
oauth2-1.4.11/lib/oauth2/client.rb:177:in `get_token'
oauth2-1.4.11/lib/oauth2/strategy/auth_code.rb:32:in `get_token'
omniauth-oauth2-1.7.3/lib/omniauth/strategies/oauth2.rb:126:in `build_access_token'
omniauth-oauth2-1.7.3/lib/omniauth/strategies/oauth2.rb:91:in `callback_phase'
omniauth-1.9.2/lib/omniauth/strategy.rb:238:in `callback_call'
omniauth-1.9.2/lib/omniauth/strategy.rb:189:in `call!'
omniauth-1.9.2/lib/omniauth/strategy.rb:169:in `call'
omniauth-1.9.2/lib/omniauth/builder.rb:45:in `call'
/var/www/discourse/lib/middleware/omniauth_bypass_middleware.rb:43:in `call'
rack-2.2.10/lib/rack/tempfile_reaper.rb:15:in `call'
rack-2.2.10/lib/rack/conditional_get.rb:27:in `call'
rack-2.2.10/lib/rack/head.rb:12:in `call'
actionpack-7.2.2/lib/action_dispatch/http/permissions_policy.rb:38:in `call'
/var/www/discourse/lib/content_security_policy/middleware.rb:12:in `call'
/var/www/discourse/lib/middleware/anonymous_cache.rb:397:in `call'
/var/www/discourse/lib/middleware/csp_script_nonce_injector.rb:12:in `call'
/var/www/discourse/config/initializers/008-rack-cors.rb:14:in `call'
rack-2.2.10/lib/rack/session/abstract/id.rb:266:in `context'
rack-2.2.10/lib/rack/session/abstract/id.rb:260:in `call'
actionpack-7.2.2/lib/action_dispatch/middleware/cookies.rb:704:in `call'
actionpack-7.2.2/lib/action_dispatch/middleware/callbacks.rb:31:in `block in call'
activesupport-7.2.2/lib/active_support/callbacks.rb:101:in `run_callbacks'
actionpack-7.2.2/lib/action_dispatch/middleware/callbacks.rb:30:in `call'
actionpack-7.2.2/lib/action_dispatch/middleware/debug_exceptions.rb:31:in `call'
actionpack-7.2.2/lib/action_dispatch/middleware/show_exceptions.rb:32:in `call'
logster-2.20.0/lib/logster/middleware/reporter.rb:40:in `call'
railties-7.2.2/lib/rails/rack/logger.rb:41:in `call_app'
railties-7.2.2/lib/rails/rack/logger.rb:29:in `call'
/var/www/discourse/config/initializers/100-quiet_logger.rb:20:in `call'
/var/www/discourse/config/initializers/100-silence_logger.rb:29:in `call'
actionpack-7.2.2/lib/action_dispatch/middleware/request_id.rb:33:in `call'
/var/www/discourse/lib/middleware/enforce_hostname.rb:24:in `call'
rack-2.2.10/lib/rack/method_override.rb:24:in `call'
actionpack-7.2.2/lib/action_dispatch/middleware/executor.rb:16:in `call'
rack-2.2.10/lib/rack/sendfile.rb:110:in `call'
rack-mini-profiler-3.3.1/lib/mini_profiler.rb:191:in `call'
/var/www/discourse/lib/middleware/processing_request.rb:12:in `call'
message_bus-4.3.8/lib/message_bus/rack/middleware.rb:60:in `call'
/var/www/discourse/lib/middleware/request_tracker.rb:360:in `call'
actionpack-7.2.2/lib/action_dispatch/middleware/remote_ip.rb:96:in `call'
railties-7.2.2/lib/rails/engine.rb:535:in `call'
railties-7.2.2/lib/rails/railtie.rb:226:in `public_send'
railties-7.2.2/lib/rails/railtie.rb:226:in `method_missing'
rack-2.2.10/lib/rack/urlmap.rb:74:in `block in call'
rack-2.2.10/lib/rack/urlmap.rb:58:in `each'
rack-2.2.10/lib/rack/urlmap.rb:58:in `call'
unicorn-6.1.0/lib/unicorn/http_server.rb:634:in `process_client'
unicorn-6.1.0/lib/unicorn/http_server.rb:739:in `worker_loop'
unicorn-6.1.0/lib/unicorn/http_server.rb:547:in `spawn_missing_workers'
unicorn-6.1.0/lib/unicorn/http_server.rb:143:in `start'
unicorn-6.1.0/bin/unicorn:128:in `<top (required)>'
/var/www/discourse/vendor/bundle/ruby/3.3.0/bin/unicorn:25:in `load'
/var/www/discourse/vendor/bundle/ruby/3.3.0/bin/unicorn:25:in `<main>'

Here is the oAuth2 settings ::

Hi there, please format the error in between triple backticks (```).

```
error message here
```
2 « J'aime »

@Steve_John I’ve formatted your post to include the logs in code blocks ```. In the future I will recommend putting error or code using what Nate suggested above.


Seeing this is a faraday formatting issue and you are successfully authenticating on refresh, I’m going to suggest you turn off this setting: oauth2_debug_auth and you should not see the error any more.

1 « J'aime »

Sure, Natalie …will follow as suggested and thanks for updating them.

Here is the current settings, Guess, you are asking to disable this settings. ::

I tried disabling this options and retesting, out of 5 attempts of relogin…one attempt again got the same error, this issue didn’t completely fix it.

Looking again, the oauth2_debug_auth setting likely takes effect when the server is started, since the oauth middleware and the logger for debugging gets attached at that time.

def register_middleware(omniauth)
  omniauth.provider :oauth2_basic,
  ...
      opts[:client_options][:connection_build] = lambda do |builder|
        if SiteSetting.oauth2_debug_auth && defined?(OAuth2FaradayFormatter)
          builder.response :logger,
                         Rails.logger,
                         { bodies: true, formatter: OAuth2FaradayFormatter }
        end
  ...
    }
end

Most site settings do not require a restart, but you will need to restart your server for this particular setting to take effect.


That said, the real underlying issue is Faraday::TimeoutError (Timeout::Error), though. I don’t think my suggestion to turn off logs will fix your problem. You will likely have to check if there are any network issues between your Discourse instance and OAuth2 provider.