Skip to content

Instantly share code, notes, and snippets.

@Benjaminhu
Created June 16, 2020 07:05
Show Gist options
  • Save Benjaminhu/be504a99a08943f5c2af2e463f4b2cc3 to your computer and use it in GitHub Desktop.
Save Benjaminhu/be504a99a08943f5c2af2e463f4b2cc3 to your computer and use it in GitHub Desktop.
<?php
include_once ' <<< PATH_TO >>> /vendor/autoload.php';
use QuickBooksOnline\API\DataService\DataService;
$config = [
'auth_mode' => 'oauth2',
'scope' => 'com.intuit.quickbooks.accounting',
'baseUrl' => 'Development',
'ClientID' => ' <<< CLIENTID >>> ',
'ClientSecret' => ' <<< CLIENTSECRET >>> ',
'RedirectUri' => ' <<< REDIRECTURI >>> ',
];
$dataService = DataService::Configure($config);
$dataService->disableLog();
if (!$_GET['callback']) {
header('Location: ' . $dataService->getOAuth2LoginHelper()->getAuthorizationCodeURL());
exit;
} else {
$code = $_REQUEST['code'];
$realmID = $_REQUEST['realmId'];
$OAuth2LoginHelper = $dataService->getOAuth2LoginHelper();
$tokens = $OAuth2LoginHelper->exchangeAuthorizationCodeForToken($code, $realmID);
$dataService->updateOAuth2Token($tokens);
// ************************************************************
// if it is not here the REQUEST and RESPONSE logos are created
// ************************************************************
$dataService->disableLog();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment