Created
June 16, 2020 07:05
-
-
Save Benjaminhu/be504a99a08943f5c2af2e463f4b2cc3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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