Access the QuickBooks Online API with OAuth2
OAuth2 required for new Intuit Developer Accounts
Starting July 17th, 2017 all new Intuit Developer accounts will need to use OAuth2 for API access. Here is how to use the QboApi gem and OAuth2.
Choosing an OAuth2 gem or not
I really won't bother trying to re-invent the wheel by rolling your own OAuth2 code. That said, the OAuth2 2-legged process is simpler than the 3-legged OAuth 1a process and if you do want to roll your own OAuth2 code take a look at Intuit's Python example for a good starting point.
As for me, I'll choose to leverage the Rack-OAuth2 gem as I like its ability to directly set endpoints.
Spinning up an OAuth2 example
- Clone the
qbo_apigem, switch into the new directory, and
Create a .env file with the
client_secretprovided within the App settings page. See Fig. 2.
- Set the OAuth2 callback or redirect URI to http://localhost:9393/oauth2-redirect
- Start up the example app
- Click on the 'Connect To QuickBooks' button, Sign in, and click on Authorize.
- The response.
- The response code.
- Click on Click here to make an API call.
$ git clone git://github.com/minimul/qbo_api && cd qbo_api $ bundle
export QBO_API_CLIENT_ID= export QBO_API_CLIENT_SECRET=
$ shotgun example/app.rb