The Intuit Developer team has written this OAuth 2.0 Sample App in Java to provide working examples how to use Java SDK to make QBO API calls using tokens generated from the OAuth Playground
In order to successfully run this sample app you need a few things:
- Java 1.8
- A developer.intuit.com account
- An app on developer.intuit.com and the associated client id and client secret.
- Clone the GitHub repo to your computer
- Fill in the
application.properties
file values (OAuth2AppClientId, OAuth2AppClientSecret) by copying over from the keys section for your app. - Use the Oauth playground to generate tokens and ill in the
application.properties
file values (accessToken, refreshToken, companyid).
Once the sample app code is on your computer, you can do the following steps to run the app:
- cd to the project directory
- Run the command:
./gradlew bootRun
(Mac OS) orgradlew.bat bootRun
(Windows) - Wait until the terminal output displays the "Started Application in xxx seconds" message.
- Your app should be up now in http://localhost:8080/
The sample app demonstrates the following flows:
QBO CompanyInfo GET API - this flow shows how to make a QBO API Get request using SDK to fetch Company Information.
QBO Create Customer POST API - this flow shows how to make a QBO API Post request using SDK to create a customer.
Handle expired tokens - Both the API calls above demonstrates how to refresh the token when token expires.
This app stores all the tokens and user information in the session. For production ready app, tokens should be encrypted and stored in a database.