ruby-on-railsrubyquickbooksquickbooks-onlineintuit-partner-platform

Failed to open TCP connection to oauth.intuit.com:443 (getaddrinfo: Name or service not known)


I'm trying to integrate my Ruby on Rails app to Quickbooks Online. I'm following the steps of this video. And I am stuck when I try to authenticate by pressing the "Connect to QuickBooks" button.

I get this error;

enter image description here

This is the Full Trace;

/home/kvothe/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/net/http.rb:960:in `initialize'
/home/kvothe/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/net/http.rb:960:in `open'
/home/kvothe/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/net/http.rb:960:in `block in connect'
/home/kvothe/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/timeout.rb:95:in `block in timeout'
/home/kvothe/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/timeout.rb:105:in `timeout'
/home/kvothe/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/net/http.rb:958:in `connect'
/home/kvothe/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/net/http.rb:943:in `do_start'
/home/kvothe/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/net/http.rb:932:in `start'

My Initializer (quickbooks.rb);

QB_KEY = "MY_CLIENT_KEY"
QB_SECRET = "MY_CLIENT_SECRET"

$qb_oauth_consumer = OAuth::Consumer.new(QB_KEY, QB_SECRET, {
    :site                 => "https://oauth.intuit.com",
    :request_token_path   => "/oauth/v1/get_request_token",
    :authorize_url        => "https://appcenter.intuit.com/Connect/Begin",
    :access_token_path    => "/oauth/v1/get_access_token"
})

Quickbooks.sandbox_mode = true

My Controller (vendors_controller.rb);

def authenticate
    callback = oauth_callback_vendors_url
    token = $qb_oauth_consumer.get_request_token(:oauth_callback => callback)
    session[:qb_request_token] = Marshal.dump(token)
    redirect_to("https://appcenter.intuit.com/Connect/Begin?oauth_token=#{token.token}") and return
end


def oauth_callback
    at = Marshal.load(session[:qb_request_token]).get_access_token(:oauth_verifier => params[:oauth_verifier])
    session[:token] = at.token
    session[:secret] = at.secret
    session[:realm_id] = params['realmId']
    redirect_to root_url, notice: "Your QuickBooks account has been successfully linked."
end

I was getting an Undefined Method: URI.escape() error but then I switched to Ruby 2.7.2

Currently using Ruby 2.7.2 and Rails 6.1.4

I think the error caused by the URL address (located in the initializer) I use to get authentication from intuit. I am using exactly the same URL's showed in the tutorial but I'm afraid it may be to old and not work anymore. But I don't know what to replace it with. And also how do I integrate my app with OAuth2.0? I can't find any recent tutorials best I got is this 7 year old tutorial by "Minimulcasts".

PS: Also when trying diffeent URL addresses I got Net::HTTPRetriableError in VendorsController#authenticate 302 "Moved Temporarily" error as well.


Solution

  • Intuit Developer no longer supports OAuth 1.

    You will need to follow the documentation on the https://developer.intuit.com platform.

    Unfortunately these docs are very outdated & support on the Help Forums is very poorly automated.