solidusio-contrib / solidus_social

Building block for social authentication in your Solidus store.
BSD 3-Clause "New" or "Revised" License
27 stars 52 forks source link

Twitter Login OAuth::Unauthorized (400 Bad Request) #85

Open Shalashtein opened 3 years ago

Shalashtein commented 3 years ago

I followed the setup instructions, added by api key and the secret key and activated the Twitter login from the admin dashboard, when I try to login I'm faced with this error. Here's the log:

2020-11-25T11:46:40.361389+00:00 app[web.1]: I, [2020-11-25T11:46:40.361222 #4]  INFO -- : [7ea80c38-c944-4ce9-ab10-127989c16d03] Started GET "/users/auth/twitter?r=0.41000514506935737" for 185.97.92.126 at 2020-11-25 11:46:40 +0000
2020-11-25T11:46:40.362139+00:00 app[web.1]: I, [2020-11-25T11:46:40.362075 #4]  INFO -- omniauth: (twitter) Calling through to underlying application for setup.
2020-11-25T11:46:40.363256+00:00 app[web.1]: I, [2020-11-25T11:46:40.363193 #4]  INFO -- omniauth: (twitter) Request phase initiated.
2020-11-25T11:46:40.517903+00:00 app[web.1]: F, [2020-11-25T11:46:40.517744 #4] FATAL -- : [7ea80c38-c944-4ce9-ab10-127989c16d03]   
2020-11-25T11:46:40.517907+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] OAuth::Unauthorized (400 Bad Request):
2020-11-25T11:46:40.517908+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03]   
2020-11-25T11:46:40.517909+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] oauth (0.5.4) lib/oauth/consumer.rb:236:in `token_request'
2020-11-25T11:46:40.517910+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] oauth (0.5.4) lib/oauth/consumer.rb:155:in `get_request_token'
2020-11-25T11:46:40.517910+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] omniauth-oauth (1.1.0) lib/omniauth/strategies/oauth.rb:28:in `request_phase'
2020-11-25T11:46:40.517911+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] omniauth-twitter (1.4.0) lib/omniauth/strategies/twitter.rb:61:in `request_phase'
2020-11-25T11:46:40.517911+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] omniauth (1.9.1) lib/omniauth/strategy.rb:226:in `request_call'
2020-11-25T11:46:40.517912+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] omniauth (1.9.1) lib/omniauth/strategy.rb:188:in `call!'
2020-11-25T11:46:40.517912+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] omniauth (1.9.1) lib/omniauth/strategy.rb:169:in `call'
2020-11-25T11:46:40.517912+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] omniauth (1.9.1) lib/omniauth/strategy.rb:192:in `call!'
2020-11-25T11:46:40.517913+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] omniauth (1.9.1) lib/omniauth/strategy.rb:169:in `call'
2020-11-25T11:46:40.517913+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] warden (1.2.9) lib/warden/manager.rb:36:in `block in call'
2020-11-25T11:46:40.517914+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] warden (1.2.9) lib/warden/manager.rb:34:in `catch'
2020-11-25T11:46:40.517914+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] warden (1.2.9) lib/warden/manager.rb:34:in `call'
2020-11-25T11:46:40.517914+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] rack (2.2.3) lib/rack/tempfile_reaper.rb:15:in `call'
2020-11-25T11:46:40.517915+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] rack (2.2.3) lib/rack/etag.rb:27:in `call'
2020-11-25T11:46:40.517918+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] rack (2.2.3) lib/rack/conditional_get.rb:27:in `call'
2020-11-25T11:46:40.517918+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] rack (2.2.3) lib/rack/head.rb:12:in `call'
2020-11-25T11:46:40.517918+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] actionpack (6.0.3.4) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
2020-11-25T11:46:40.517919+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] rack (2.2.3) lib/rack/session/abstract/id.rb:266:in `context'
2020-11-25T11:46:40.517919+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] rack (2.2.3) lib/rack/session/abstract/id.rb:260:in `call'
2020-11-25T11:46:40.517920+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] actionpack (6.0.3.4) lib/action_dispatch/middleware/cookies.rb:648:in `call'
2020-11-25T11:46:40.517920+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] actionpack (6.0.3.4) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
2020-11-25T11:46:40.517921+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] activesupport (6.0.3.4) lib/active_support/callbacks.rb:101:in `run_callbacks'
2020-11-25T11:46:40.517921+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] actionpack (6.0.3.4) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
2020-11-25T11:46:40.517922+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] actionpack (6.0.3.4) lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
2020-11-25T11:46:40.517923+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] actionpack (6.0.3.4) lib/action_dispatch/middleware/debug_exceptions.rb:32:in `call'
2020-11-25T11:46:40.517923+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] actionpack (6.0.3.4) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
2020-11-25T11:46:40.517923+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] railties (6.0.3.4) lib/rails/rack/logger.rb:37:in `call_app'
2020-11-25T11:46:40.517924+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] railties (6.0.3.4) lib/rails/rack/logger.rb:26:in `block in call'
2020-11-25T11:46:40.517924+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] activesupport (6.0.3.4) lib/active_support/tagged_logging.rb:80:in `block in tagged'
2020-11-25T11:46:40.517925+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] activesupport (6.0.3.4) lib/active_support/tagged_logging.rb:28:in `tagged'
2020-11-25T11:46:40.517925+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] activesupport (6.0.3.4) lib/active_support/tagged_logging.rb:80:in `tagged'
2020-11-25T11:46:40.517925+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] railties (6.0.3.4) lib/rails/rack/logger.rb:26:in `call'
2020-11-25T11:46:40.517926+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] actionpack (6.0.3.4) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
2020-11-25T11:46:40.517926+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] actionpack (6.0.3.4) lib/action_dispatch/middleware/request_id.rb:27:in `call'
2020-11-25T11:46:40.517927+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] rack (2.2.3) lib/rack/method_override.rb:24:in `call'
2020-11-25T11:46:40.517927+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] rack (2.2.3) lib/rack/runtime.rb:22:in `call'
2020-11-25T11:46:40.517934+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] activesupport (6.0.3.4) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
2020-11-25T11:46:40.517935+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] actionpack (6.0.3.4) lib/action_dispatch/middleware/executor.rb:14:in `call'
2020-11-25T11:46:40.517935+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] actionpack (6.0.3.4) lib/action_dispatch/middleware/static.rb:126:in `call'
2020-11-25T11:46:40.517936+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] rack (2.2.3) lib/rack/sendfile.rb:110:in `call'
2020-11-25T11:46:40.517936+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] actionpack (6.0.3.4) lib/action_dispatch/middleware/host_authorization.rb:76:in `call'
2020-11-25T11:46:40.517936+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] railties (6.0.3.4) lib/rails/engine.rb:527:in `call'
2020-11-25T11:46:40.517937+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] puma (4.3.6) lib/puma/configuration.rb:228:in `call'
2020-11-25T11:46:40.517937+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] puma (4.3.6) lib/puma/server.rb:713:in `handle_request'
2020-11-25T11:46:40.517938+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] puma (4.3.6) lib/puma/server.rb:472:in `process_client'
2020-11-25T11:46:40.517938+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] puma (4.3.6) lib/puma/server.rb:328:in `block in run'
2020-11-25T11:46:40.517938+00:00 app[web.1]: [7ea80c38-c944-4ce9-ab10-127989c16d03] puma (4.3.6) lib/puma/thread_pool.rb:134:in `block in spawn_thread'
2020-11-25T11:46:40.519319+00:00 heroku[router]: at=info method=GET path="/users/auth/twitter?r=0.41000514506935737" host=labbesne.herokuapp.com request_id=7ea80c38-c944-4ce9-ab10-127989c16d03 fwd="185.97.92.126" dyno=web.1 connect=1ms service=159ms status=500 bytes=1827 protocol=https
2020-11-25T11:46:41.186274+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=labbesne.herokuapp.com request_id=ae9d6f11-84cc-49b4-aa93-8445e5373a93 fwd="185.97.92.126" dyno=web.1 connect=0ms service=4ms status=304 bytes=48 protocol=https
Anuragjain89 commented 3 years ago

@Shalashtein Please try if the solution provided in this thread works for you https://github.com/arunagw/omniauth-twitter/issues/105

Shalashtein commented 3 years ago

@Shalashtein Please try if the solution provided in this thread works for you https://github.com/arunagw/omniauth-twitter/issues/105

Unfortunately not, they're already called api_key and api_secret be default in this gem

Anuragjain89 commented 3 years ago

@Shalashtein Please try if the solution provided in this thread works for you arunagw/omniauth-twitter#105

Unfortunately not, they're already called api_key and api_secret be default in this gem

As per this comment ( although a 2016 one but might work ) , you may try changing that name to consumer_key and consumer_secret.

Shalashtein commented 3 years ago

I tried changing

config.providers = {
    twitter: {
      api_key: ENV['s2WF7cQbT7Ekxi8Jt4JT2sC1J'],
      api_secret: ENV['upVvTRHa0Puuweu2dRNcLccgOFoZCsQdjpMiaVq5uNa3Qig7HM'],
    }
  }
end

to

config.providers = {
    twitter: {
      consumer_key: ENV['s2WF7cQbT7Ekxi8Jt4JT2sC1J'],
      consumer_secret: ENV['upVvTRHa0Puuweu2dRNcLccgOFoZCsQdjpMiaVq5uNa3Qig7HM'],
    }
  }
end

same error, but these are only variable names. I ran the marshal_dump method and I got this

{:key=>nil, :secret=>nil, :options=>{:signature_method=>"HMAC-SHA1", :request_token_path=>"/oauth/request_token", :authorize_path=>"/oauth/authenticate", :access_token_path=>"/oauth/access_token", :proxy=>nil, :scheme=>:header, :http_method=>:post, :debug_output=>nil, :oauth_version=>"1.0", :site=>"https://api.twitter.com"}}

Perhaps there's a logical error in the gem itself because it doesn't seem to be including the key and secret in the http request