1- /**
2- * Populate constants with data specific to your application,
3- * found at https://developer.intuit.com/v2/ui#/app/appdetail/XXXXXXX
1+ /*
2+ * This sample demonstrates how to configure the library for the Intuit Quickbooks API.
3+ * Instructions for obtaining your Client ID and Client Secret can be found here:
4+ * https://developer.intuit.com/app/developer/qbo/docs/get-started
45 */
5- var CLIENT_ID = '...' ;
6- var CLIENT_SECRET = '...' ;
76
8- // URLS found at Quickbooks Devloper Portal: https://developer.intuit.com
9- var BASE_AUTH_URL = 'https://appcenter.intuit.com/connect/oauth2' ;
10- var TOKEN_URL = 'https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer' ;
7+ var CLIENT_ID = '' ;
8+ var CLIENT_SECRET = '' ;
119
1210/**
1311 * Log the redirect URI to be pasted in the Intuit Dev Center:
@@ -61,14 +59,20 @@ function reset() {
6159function getService ( ) {
6260 return OAuth2 . createService ( 'Quickbooks' )
6361 // Set the endpoint URLs.
64- . setAuthorizationBaseUrl ( BASE_AUTH_URL )
65- . setTokenUrl ( TOKEN_URL )
62+ . setAuthorizationBaseUrl ( 'https://appcenter.intuit.com/connect/oauth2' )
63+ . setTokenUrl ( 'https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer' )
64+
6665 // Set the client ID and secret.
6766 . setClientId ( CLIENT_ID )
6867 . setClientSecret ( CLIENT_SECRET )
68+
69+ // Required, set to Accounting for this example, see QB developer portal for additional options.
70+ . setScope ( 'com.intuit.quickbooks.accounting' )
71+
6972 // Set the name of the callback function in the script referenced
7073 // above that should be invoked to complete the OAuth flow.
7174 . setCallbackFunction ( 'authCallback' )
75+
7276 // Set the property store where authorized tokens should be persisted.
7377 . setPropertyStore ( PropertiesService . getUserProperties ( ) ) ;
7478}
@@ -80,9 +84,8 @@ function authCallback(request) {
8084 var service = getService ( ) ;
8185 var authorized = service . handleCallback ( request ) ;
8286 if ( authorized ) {
83- PropertiesService . getUserProperties ( )
84- . setProperty ( 'QuickBooks.companyId' , request . parameter . realmId ) ;
85- Logger . log ( 'Success!' ) ;
87+ // Save the Company ID in the service's storage.
88+ service . getStorage ( ) . setValue ( 'QuickBooks.companyId' , request . parameter . realmId ) ;
8689 return HtmlService . createHtmlOutput ( 'Success!' ) ;
8790 } else {
8891 return HtmlService . createHtmlOutput ( 'Denied' ) ;
0 commit comments