Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

413 error while authenticating with omniauth-twitter when this gem is in the bundle #26

Closed
diogob opened this issue Jun 27, 2012 · 8 comments

Comments

@diogob
Copy link

diogob commented Jun 27, 2012

I've set up a repo to make it easier to reproduce the error: https://github.com/diogob/demo_paypal_omniauth
Steps to reproduce the bug:

  1. Clone the repo and setup the rails app (bundle, db:create and all that jazz)
  2. Edit the config/initializers/omniauth.rb and insert a valid key and secret to an oauth twitter application
  3. Start the server using thin: rails s thin (have not tested with webrick)
  4. Access the address: http://localhost:3000/auth/twitter
  5. It should respond with:
    OAuth::Unauthorized
    413 Request Entity Too Large

If you just comment out the active_paypal_adaptive_payment from the Gemfile, reinstall the bundle and restart the server, the twitter auth works as expected (and leads to a non-existent SessionController).

BTW, the error does not depend on the presence of the gem activemerchant in the Gemfile.
I would guess that it has something to do with the file active_paypal_adaptive_payment / lib / active_merchant / billing / gateways / paypal_adaptive_payments / ext.rb

Strange indeed!

Best Regards

@jpablobr
Copy link
Owner

Hey, thanks for setting the repo!

Can you try to see what happen if you add the following to your config/environments/development.rb

App::Application.configure do
  config.setting...
end
ActiveMerchant::Billing::Base.mode = :test

@diogob
Copy link
Author

diogob commented Jun 27, 2012

The error persists after adding the line.
BTW, I've reproduced the bug in production env (is the same bug present in http://catarse-test.herokuapp.com/auth/twitter)

@jpablobr
Copy link
Owner

jpablobr commented Jul 3, 2012

I was able to recreate the error, but that 413 is kind of cryptic error :( Are you still having the issue?

@diogob
Copy link
Author

diogob commented Jul 3, 2012

Yeah, I had to remove the gem to keep using the twitter authentication.

On Tue, Jul 3, 2012 at 9:16 AM, Jose Pablo Barrantes <
reply@reply.github.com

wrote:

I was able to recreate the error, but that 413 is kind of cryptic error :(
Are you still having the issue?


Reply to this email directly or view it on GitHub:

#26 (comment)

@budnik
Copy link

budnik commented Jul 6, 2012

I had to patch oauth-ruby in order to both active_paypal_adaptive_payment and omniauth-twitter work in my project:
https://github.com/dmitriybudnik/oauth-ruby/commit/4731a822431f838019b9dfca787cf9f97eee3d3a#L0R338

@jpablobr
Copy link
Owner

jpablobr commented Jul 6, 2012

@dmitriybudnik thanks for letting us know! 🤘

@jpablobr jpablobr closed this as completed Jul 6, 2012
@budnik
Copy link

budnik commented Jul 6, 2012

I've nailed it down to be caused by monkey-patching Net::HTTPHeader#[]= here:
https://github.com/jpablobr/active_paypal_adaptive_payment/blob/master/lib/active_merchant/billing/gateways/paypal_adaptive_payments/ext.rb#L32-42
it just strips down-casing of header-name out off original method:
https://github.com/ruby/ruby/blob/70271340af90bdfedd52854b45704cb488946d92/lib/net/http.rb#L1160-1166
Why it's there?

@jpablobr
Copy link
Owner

jpablobr commented Jul 8, 2012

@dmitriybudnik to be honest I don't remember and I'm actually not working with this gem any more...

That said :/, I guess it has something to do with the way PayPal validates headers... they always come with weird sh*t! But it might very well be that they change it and the downcase hack is not be needed any more.

Would you be able to test that? if so, and if it works... I'll be more than happy to accept a pull request.

Many thanks for your debugging efforts! :)

budnik added a commit to budnik/active_paypal_adaptive_payment that referenced this issue Jul 9, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants