ruckus / quickbooks-ruby

Quickbooks Online REST API V3 - Ruby
MIT License
374 stars 302 forks source link

undefined method `connection=' for #<IntuitOAuth::Client:0x007f8d9e1e6bc0> #491

Closed varun43in closed 4 years ago

varun43in commented 4 years ago

I have successfully migrated a client form oAuth 1.0 to oAuth 2.0 and received the access_token and refresh_token.

Now i'm trying to get the company preferences using oAuth 2.0, and getting an error.
undefined method 'connection=' for #

Please see my code below:

access_token = OAuth2::AccessToken.new($oauth2_client, access_token, :refresh_token => refresh_token)

service = Quickbooks::Service::Preferences.new
service.company_id = realm_id
service.access_token = access_token
preferences = service.query("Select * from Preferences")

I'm using the latest gem version gem "quickbooks-ruby", '1.0.1'

Thanks for your help!

ruckus commented 4 years ago

IntuitOAuth::Client is your app? Thats nothing from the gem. Can you post stacktrace?

varun43in commented 4 years ago

I'm used this gem as recommended by QBO article: https://developer.intuit.com/app/developer/qbo/docs/develop/authentication-and-authorization/oauth-2.0#download-the-oauth-library

gem 'intuit-oauth'

Stack trace:

NoMethodError (undefined method `connection=' for #<IntuitOAuth::Client:0x007ff4c86c2ea0>):
  app/controllers/quickbooks_controller.rb:432:in `test_api_3'

NoMethodError (undefined method `connection=' for #<IntuitOAuth::Client:0x007ff4c86c2ea0>):
  app/controllers/quickbooks_controller.rb:432:in `test_api_3'

  Rendered /Users/varunaggarwal/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/actionpack-4.2.8/lib/action_dispatch/middleware/templates/rescues/_source.erb (6.9ms)
  Rendered /Users/varunaggarwal/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/actionpack-4.2.8/lib/action_dispatch/middleware/templates/rescues/_source.erb (6.9ms)
  Rendered /Users/varunaggarwal/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/actionpack-4.2.8/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (4.5ms)
  Rendered /Users/varunaggarwal/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/actionpack-4.2.8/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (4.5ms)
  Rendered /Users/varunaggarwal/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/actionpack-4.2.8/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.5ms)
  Rendered /Users/varunaggarwal/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/actionpack-4.2.8/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.5ms)
  Rendered /Users/varunaggarwal/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/actionpack-4.2.8/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (217.9ms)
  Rendered /Users/varunaggarwal/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/actionpack-4.2.8/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (217.9ms)
ruckus commented 4 years ago

If you're using this gem (quickbooks-ruby) then you don't need that gem. Well, perhaps you could've used it just for migrating tokens, but once you've done that, it shouldn't be necessary

varun43in commented 4 years ago

So after i've migrated the tokens, I should remove the intuit-oauth gem And then my current code, which is using only the quickbooks-ruby gem, will work using the new oAuth 2 tokens?

varun43in commented 4 years ago

You are right. It's working for me now. Thanks man!!