|
1 | 1 | # HelloWorld-Java |
2 | | -Starter app in Java using OAuth2 that demonstrates how to make a QBO API Call |
| 2 | + |
| 3 | +The [Intuit Developer team](https://developer.intuit.com) has written this starter app in Java using OAuth2.0 to provide working examples of OAuth 2.0 concepts, and how to integrate with Intuit endpoints. |
| 4 | + |
| 5 | +## Table of Contents |
| 6 | + |
| 7 | +* [Requirements](#requirements) |
| 8 | +* [First Use Instructions](#first-use-instructions) |
| 9 | +* [Running the code](#running-the-code) |
| 10 | +* [Configuring the callback endpoint](#configuring-the-callback-endpoint) |
| 11 | +* [Getting the OAuth Tokens](#getting-the-oauth-tokens) |
| 12 | +* [Scope](#scope) |
| 13 | +* [Storing the Tokens](#storing-the-tokens) |
| 14 | +* [Discovery document](#discovery-document) |
| 15 | + |
| 16 | + |
| 17 | +## Requirements |
| 18 | + |
| 19 | +In order to successfully run this sample app you need a few things: |
| 20 | + |
| 21 | +1. Java 1.8 |
| 22 | +2. A [developer.intuit.com](http://developer.intuit.com) account |
| 23 | +3. An app on [developer.intuit.com](http://developer.intuit.com) and the associated client id and client secret. |
| 24 | + |
| 25 | +## First Use Instructions |
| 26 | + |
| 27 | +1. Clone the GitHub repo to your computer |
| 28 | +2. Fill in the [`application.properties`](src/main/resources/application.properties) file values (OAuth2AppClientId, OAuth2AppClientSecret) by copying over from the keys section for your app. |
| 29 | + |
| 30 | +## Running the code |
| 31 | + |
| 32 | +Once the sample app code is on your computer, you can do the following steps to run the app: |
| 33 | + |
| 34 | +1. cd to the project directory</li> |
| 35 | +2. Run the command:`./gradlew bootRun` (Mac OS) or `gradlew.bat bootRun` (Windows)</li> |
| 36 | +3. Wait until the terminal output displays the "Started Application in xxx seconds" message. |
| 37 | +4. Your app should be up now in http://localhost:8080/ |
| 38 | +5. The oauth2 callback endpoint in the sample app is http://localhost:8080/oauth2redirect |
| 39 | +6. To run the code on a different port, uncomment and update server.port property in application.properties. Also make sure to update the url in application.properties and in the Developer portal ("Keys" section). |
| 40 | + |
| 41 | +## Configuring the callback endpoint |
| 42 | +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). |
| 43 | + |
| 44 | +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. |
| 45 | + |
| 46 | +## Getting the OAuth Tokens |
| 47 | + |
| 48 | +The sample app supports the following flows: |
| 49 | + |
| 50 | +**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. |
| 51 | + |
| 52 | +**Get CompanyInfor API** - This flow can be triggered from the connected page. It queries the QuickBooks CompanyInfo API and retrieves the response. |
| 53 | + |
| 54 | +## Scope |
| 55 | + |
| 56 | +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 the`com.intuit.quickbooks.payment` scope in the `application.properties` file connectToQuickbooks method. |
| 57 | + |
| 58 | +## Storing the tokens |
| 59 | +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. |
0 commit comments