Skip to content

Commit 9370dc4

Browse files
committed
initial commit
1 parent 2d8b960 commit 9370dc4

20 files changed

Lines changed: 956 additions & 1 deletion

‎README.md‎

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,59 @@
11
# 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.

‎build.gradle‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
buildscript {
3+
repositories {
4+
mavenCentral()
5+
}
6+
dependencies {
7+
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.5.RELEASE")
8+
}
9+
}
10+
11+
apply plugin: 'java'
12+
apply plugin: 'eclipse'
13+
apply plugin: 'idea'
14+
apply plugin: 'spring-boot'
15+
16+
jar {
17+
baseName = 'hello-world-java'
18+
version = '0.1.0'
19+
}
20+
21+
repositories {
22+
mavenCentral()
23+
mavenLocal()
24+
}
25+
26+
sourceCompatibility = 1.8
27+
targetCompatibility = 1.8
28+
29+
dependencies {
30+
compile("com.intuit.quickbooks-online:ipp-v3-java-data:4.0.1")
31+
compile (group: 'com.intuit.quickbooks-online', name: 'ipp-v3-java-devkit', version: '4.0.1', classifier: 'jar-with-dependencies')
32+
compile (group: 'com.intuit.quickbooks-online', name: 'oauth2-platform-api', version: '4.0.1', classifier: 'jar-with-dependencies')
33+
compile("org.springframework.boot:spring-boot-starter-web")
34+
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
35+
compile("org.springframework.data:spring-data-rest-webmvc")
36+
compile("org.json:json")
37+
compile("log4j:log4j")
38+
testCompile('org.springframework.boot:spring-boot-starter-test')
39+
40+
}
41+
42+
task wrapper(type: Wrapper) {
43+
gradleVersion = '2.3'
44+
}

‎gradle/wrapper/gradle-wrapper.jar‎

52.4 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Fri Mar 23 21:30:28 PDT 2018
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-bin.zip

‎gradlew‎

Lines changed: 160 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎gradlew.bat‎

Lines changed: 90 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎settings.gradle‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* This settings file was auto generated by the Gradle buildInit task
3+
* by 'cderose' at '3/23/18 9:30 PM' with Gradle 2.9
4+
*
5+
* The settings file is used to specify which projects to include in your build.
6+
* In a single project build this file can be empty or even removed.
7+
*
8+
* Detailed information about configuring a multi-project build in Gradle can be found
9+
* in the user guide at https://docs.gradle.org/2.9/userguide/multi_project_builds.html
10+
*/
11+
12+
/*
13+
// To declare projects as part of a multi-project build use the 'include' method
14+
include 'shared'
15+
include 'api'
16+
include 'services:webservice'
17+
*/
18+
19+
rootProject.name = 'HelloWorld-Java'

0 commit comments

Comments
 (0)