Get 50% OFF QuickBooks for 3 months*

Buy now
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements
Work smarter and get more done with advanced tools that save you time. Discover QuickBooks Online Advanced.

Reply to message

View discussion in a popup

Replying to:
luisfbn
Level 1

Reply to message

I'm having the same error. See the following code.

 

$settings = [
'auth_mode' => 'oauth2',
'ClientID' => 'client id',
'ClientSecret' => 'client secret',
'RedirectURI' => 'http://example.test/redirect',
'accessTokenKey' => 'token key',
'refreshTokenKey' => 'refresh token key',
'QBORealmID' => 'my realm',
'scope' => 'com.intuit.quickbooks.accounting',
'baseUrl' => 'Development'
];
$dataService = DataService::Configure($settings);

$OAuth2LoginHelper = $dataService->getOAuth2LoginHelper();

try {
$refreshedAccessTokenObj = $OAuth2LoginHelper->refreshToken();
} catch (\Exception $exception) {
// throws exception, answer from QBO
// Incorrect Token type or clientID
var_dump($exception);
}

$error = $OAuth2LoginHelper->getLastError();
if($error){
echo 'got error'.PHP_EOL;
var_dump($error);
} else {
echo 'update auth token'.PHP_EOL;
//Refresh Token is called successfully
$dataService->updateOAuth2Token($refreshedAccessTokenObj);
}

// the token is valid
// I can see company info
echo 'get company info'.PHP_EOL;
print_r($dataService->getCompanyInfo());

 

Need to get in touch?

Contact us