Skip to content

Latest commit

 

History

History
74 lines (41 loc) · 3.63 KB

README.md

File metadata and controls

74 lines (41 loc) · 3.63 KB

Java Sample for OAuth

Welcome to the Intuit Developer's Java OAuth Sample App.

This sample app is meant to provide a working example of oAuth management.

OAuth Management APIs consists of the following:

Intuit OAuth Service URLs - URLs to use to access Intuit OAuth Services. Request token URL - Request token endpoint to retrieve request token and secret Access token URL - Access token endpoint to retrieve access token and secret Authorize URL - To authorize access to the third party app

This is not a seed project to be taken cart blanche and deployed to your production environment. Certain concerns are not addressed at all in our samples (e.g. security, privacy, scalability). In our sample apps, we strive to strike a balance between clarity, maintainability, and performance where we can. However, clarity is ultimately the most important quality in a sample app.

Table of Contents

Prerequisites
First Use Instructions
Running the app
Project Structure

Prerequisites:

• Latest version of Java - This sample uses Java 1.7
• Maven
• Apache Tomcat or any webserver (the sample is configured to run on port 8080, if you are using a different port number, please update the code accordingly)
• For Oauth implementation, this sample uses the Java signpost library (https://code.google.com/p/oauth-signpost/)
• Developer.intuit.com account
• An app on developer.intuit.com and the associated app token, consumer key, and consumer secret.

First Use Instructions:

• Clone the GitHub repo to your workspace

Note: This sample is using the sandbox environment by default. So, you need to use the development tokens of your app to run this sample. If you want to switch to production, please make sure that you change the qbo_url in app.properties file inside OauthSample folder to quickbooks.api.intuit.com from sandbox-quickbooks.api.intuit.com. Also, make sure that you configure the sample app to use prod tokens instead of development tokens.

• Configure the app tokens: Go to your app on developer.intuit.com and copy the OAuth Consumer Key and OAuth Consumer Token from the keys tab. Add these values to the app.properties file in our OauthSample folder.

• Build the code using mvn install (either from IDE or from command prompt)

• Deploy the generated war file to the webserver.

Run the App:

Once the sample app code is on your computer, follow the steps below to run the app:

• Launch the app - http://localhost:8080/OauthSample

• Connect your app to Quickbooks, by clicking on ‚”Connect to QuickBooks” button and follow the instructions on the screen.

• After successfully connecting the app to QuickBooks, you can view the realmID, Oauth token and Oauth secret in your server logs.

• You will be redirected to the findallcustomers.jsp that makes a call to the QBO Customer endpoint to read a customer record (by Id).

Project Structure:

• RequestTokenServlet.java: Servlet to trigger the Oauth flow, calls the request token endpoint. Response is sent to Oauth callback URL
• AccessTokenServlet.java: This is the OauthCallback URL as configured in app.properties. Reads the params from HttpSession and calls the access token endpoint to retrieve access token and secret
• OauthUtils.java : Reads the properties file
• app.properties : Configure the consumer key, secret, Oauth callback URL and QBO URL in this file
• index.jsp: Contains the code for adding "Connect to QuickBooks" button.
• connect.jsp: Close the Oauth popup and redirect to findallcustomers.jsp
• findallcustomers.jsp: Code needed for calling the QBO Customer endpoint to retrieve all customers