This is a sample Java application that demonstrates how to integrate with QuickBooks APIs using OAuth 2.0 authentication and use payroll compensation types in time activities.
- OAuth 2.0 authentication with QuickBooks
- Payroll API integration via GraphQL
- Java 17 or higher
- Gradle 7.0 or higher
- QuickBooks Developer Account
- QuickBooks Online Account
- ngrok (for local development)
The API requires the following OAuth scopes for full functionality:
com.intuit.quickbooks.accounting- Access to QuickBooks accounting dataproject-management.project- Required for Projects API accesspayroll.compensation.read- Required for Payroll API access
-
Clone the repository:
git clone <repository-url> cd SampleApp-Payroll-Java
-
Configure your QuickBooks app:
- Go to Intuit Developer Portal
- Create a new app or use an existing one
- Enable Payroll, Project and Accounting API scopes
- Add your redirect URI (e.g.,
https://your-ngrok-url/callback)
-
Update configuration:
- Open
src/main/resources/application.yml - Update the OAuth2 provider details with your app credentials:
quickbooks: client-id: YOUR_CLIENT_ID client-secret: YOUR_CLIENT_SECRET redirect-uri: YOUR_REDIRECT_URI
- Set the minor version and the environment as appropriate:
quickbooks: minor-version: 75 environment: production
- Open
-
Start ngrok:
ngrok http 8080
-
Run the application:
./gradlew bootRun
- Visit
http://localhost:8080in your browser - Step 1: Connect to QuickBooks - Click "Connect to QuickBooks" to authenticate
- Step 2: Fetch Data - Click "Fetch Data" to load employee and project data automatically
- Step 3: Fetch Compensations - Click "Fetch Compensations" to load compensation data for the selected employee
- Step 4: Enter Info - Select a compensation type and optionally a project for which you want to create a time activity. Then enter the hours and minutes worked.
- Step 5: Create Time Activity - Click "Create Time Activity" to create the specified time activity for your company.
SampleApp-Payroll-Java/
├── src/main/java/com/quickbooks/demo/
│ ├── Application.java # Main application file
│ ├── config/ # Configuration classes
│ ├── controller/ # Web controllers
│ ├── service/ # Business logic services
├── src/main/resources/
│ ├── application.yml # Configuration settings
│ ├── graphql/ # GraphQL queries and mutations
│ ├── static/ # Static files (CSS, images)
│ └── templates/ # HTML templates
└── README.md
/- Home page with multi-step workflow/qbo-login- Initiates OAuth flow/callback- OAuth callback handler/datafetch- Retrieves employee and project data automatically/fetch-compensations- Retrieves compensation data for the selected employee/create-time-activity- Creates a time activity in QuickBooks/logout- Logs out of QuickBooks
The application includes error handling for:
- OAuth authentication failures
- API request failures
- Missing parameters
- Invalid scopes
-
"Forbidden" Error
- Ensure
project-management.projectandpayroll.compensation.readscopes are included in OAuth authorization - Check that all required scopes are configured in
application.yml
- Ensure
-
"Invalid URI or environment" Error
- Verify
Environmentis set to"production" - Check that
RedirectUrimatches your QuickBooks app configuration
- Verify
-
GraphQL Query Errors
- Filtered queries use
projectManagementProjectsorgetEmployeeCompensations(with 's') - Ensure proper variable types:
ProjectManagement_ProjectFilter!for filtered projects orPayroll_EmployeeCompensationsFilter!for compensations
- Filtered queries use
All API requests that the app makes are logged at DEBUG level. Reponses are logged in the same way, unless the request fails. In that case, the response is logged at ERROR level.
Please set the required logging level in application.yml.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
For support, please visit the Intuit Developer Community or create an issue in this repository.