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

Bug when configuring OAuth #141

Closed
achadee opened this issue Apr 18, 2017 · 5 comments
Closed

Bug when configuring OAuth #141

achadee opened this issue Apr 18, 2017 · 5 comments
Assignees
Labels

Comments

@achadee
Copy link

achadee commented Apr 18, 2017

I feel like the thread safe methods weren't tested very well with OAuth.

Im getting this error:

NoMethodError: undefined method `each' for nil:NilClass
	from /Users/achadee/.rvm/gems/ruby-2.1.2/gems/faraday-0.12.0.1/lib/faraday/options.rb:49:in `merge!'
	from /Users/achadee/.rvm/gems/ruby-2.1.2/gems/faraday-0.12.0.1/lib/faraday/options.rb:60:in `merge'
	from /Users/achadee/.rvm/gems/ruby-2.1.2/gems/faraday-0.12.0.1/lib/faraday/options.rb:52:in `block in merge!'
	from /Users/achadee/.rvm/gems/ruby-2.1.2/gems/faraday-0.12.0.1/lib/faraday/options.rb:49:in `each'
	from /Users/achadee/.rvm/gems/ruby-2.1.2/gems/faraday-0.12.0.1/lib/faraday/options.rb:49:in `merge!'
	from /Users/achadee/.rvm/gems/ruby-2.1.2/gems/faraday-0.12.0.1/lib/faraday/options.rb:60:in `merge'
	from /Users/achadee/.rvm/gems/ruby-2.1.2/gems/faraday-0.12.0.1/lib/faraday/connection.rb:61:in `initialize'
	from /Users/achadee/.rvm/gems/ruby-2.1.2/gems/faraday-0.12.0.1/lib/faraday.rb:67:in `new'
	from /Users/achadee/.rvm/gems/ruby-2.1.2/gems/faraday-0.12.0.1/lib/faraday.rb:67:in `new'
	from /Users/achadee/.rvm/gems/ruby-2.1.2/gems/bigcommerce-1.0.0/lib/bigcommerce/connection.rb:11:in `build'
	from /Users/achadee/Projects/anthq/gems/ant_bigcommerce/lib/ant_bigcommerce/connection.rb:66:in `setup'
	from (irb):1
	from bin/console:15:in `<main>'

Which is obviously being caused by this line:

https://github.com/bigcommerce/bigcommerce-api-ruby/blob/v1.0.0/lib/bigcommerce/connection.rb#L10

Because the ssl_options are being set to nil and its trying to iterate over the keys.

I ran the Faraday method manually and set the ssl_options to an empty hash {} instead of a nil and it worked first time. Surely others are experiencing this issue?

my code:

      connection = ::Bigcommerce::Connection.build(
        ::Bigcommerce::Config.new(
          store_hash: credentials[:context],
          client_id: ENV['BC_CLIENT_ID'],
          access_token: credentials[:access_token],
        )
      )
@pedelman
Copy link
Contributor

Thanks for filing such a detailed ticket. Are you using a new connection for each thread or trying to share a connection between threads? Can you give more context into the kinds of requests you are making and maybe an example of the threaded code?

@achadee
Copy link
Author

achadee commented May 1, 2017

I'm using a new connection per thread. I can't even make a request, because faraday throws the error above when I write the code I wrote above

@pedelman
Copy link
Contributor

pedelman commented May 1, 2017

It seems the bug is that Faraday has resolved to a newer version in the Gemspec and that version included breaking changes. The specs are currently broken on master.

Will open PR soon. Thanks for reporting, this does not appear to be related to any thread safety concerns.

Until the fix is up, you can either point faraday down a few minor versions (I will update gemspec to fix future issue) or you can apply a patch to that line, for testing I changed it to:

ssl_options = config.ssl || {}

I see no problem opening up the ssl_options on the oauth api side of things.

@pedelman
Copy link
Contributor

pedelman commented May 2, 2017

This should be fixed in master.

@pedelman pedelman closed this as completed May 2, 2017
@achadee
Copy link
Author

achadee commented May 10, 2017

awesome, I wrote my own wrapper for now, but will move back to this when you guys release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants