Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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