Skip to content
Java sample app for OAuth2
Branch: master
Clone or download
Latest commit cb499c7 Mar 5, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
gradle/wrapper updated properties and version Mar 4, 2019
src/main updated properties and version Mar 4, 2019
views update PRS widget Apr 19, 2018
LICENSE.txt add license Jul 12, 2017 update PRS widget Apr 19, 2018
build.gradle removed org.json Mar 5, 2019
gradlew initial commit Jul 12, 2017
gradlew.bat initial commit Jul 12, 2017
settings.gradle initial commit Jul 12, 2017

Sample Banner

OAuth2 - Java Sample App

The Intuit Developer team has written this OAuth 2.0 Sample App in Java to provide working examples of OAuth 2.0 concepts, and how to integrate with Intuit endpoints.

Table of Contents


In order to successfully run this sample app you need a few things:

  1. Java 1.8
  2. A account
  3. An app on and the associated client id and client secret.

First Use Instructions

  1. Clone the GitHub repo to your computer
  2. Fill in the file values (OAuth2AppClientId, OAuth2AppClientSecret) by copying over from the keys section for your app.

Running the code

Once the sample app code is on your computer, you can do the following steps to run the app:

  1. cd to the project directory
  2. Run the command:./gradlew bootRun (Mac OS) or gradlew.bat bootRun (Windows)
  3. Wait until the terminal output displays the "Started Application in xxx seconds" message.
  4. Your app should be up now in http://localhost:8080/
  5. The oauth2 callback endpoint in the sample app is http://localhost:8080/oauth2redirect
  6. To run the code on a different port, uncomment and update server.port property in

Configuring the callback endpoint

You'll have to set a Redirect URI in the Developer Portal ("Keys" section). With this app, the typical value would be http://localhost:8080/oauth2redirect, unless you host this sample app in a different way (if you were testing HTTPS, for example).

Note: Using localhost and http will only work when developing, using the sandbox credentials. Once you use production credentials, you'll need to host your app over https.

Getting the OAuth Tokens

The sample app supports the following flows:

Sign In With Intuit - this flow requests OpenID only scopes. Feel free to change the scopes being requested in After authorizing (or if the account you are using has already been authorized for this app), the redirect URL (/oauth2redirect) will parse the JWT ID token, and make an API call to the user information endpoint.

Connect To QuickBooks - this flow requests non-OpenID scopes. You will be able to make a QuickBooks API sample call (using the OAuth2 token) on the /connected landing page. Sample implementation for RefreshToken and RevokeToken is also available in that page.

Get App Now (Connect Handler) - this flow requests both OpenID and non-OpenID scopes. It simulates the request that would come once a user clicks "Get App Now" on the website, after you publish your app.


It is important to ensure that the scopes your are requesting match the scopes allowed on the Developer Portal. For this sample app to work by default, your app on Developer Portal must support Accounting scopes. If you'd like to support both Accounting and Payment, simply add scope in the file.

Storing the tokens

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.

Discovery document

The app calls the discovery API during starup and loads all the endpoint urls. For production ready app, make sure to run this API once a day to get the latest urls.

You can’t perform that action at this time.