Skip to content

Commit

Permalink
Fixes #181, adds OAuth v2 support.
Browse files Browse the repository at this point in the history
  • Loading branch information
keith-chargeover committed May 16, 2019
1 parent 8797b41 commit 258ebd0
Show file tree
Hide file tree
Showing 9 changed files with 337 additions and 317 deletions.
14 changes: 6 additions & 8 deletions QuickBooks/Driver/Sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -2149,7 +2149,7 @@ protected function _oauthRequestResolveV2($state)
" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_OAUTHV2TABLE) . "
WHERE
oauth_state = '%s' AND
request_datetime >= '%s'
request_datetime >= '%s'
", $errnum, $errmsg, null, null, array( $state, date('Y-m-d H:i:s', strtotime('-30 minutes')) )));
}

Expand Down Expand Up @@ -2275,9 +2275,8 @@ protected function _oauthRequestWriteV1($app_tenant, $token, $token_secret)
// Insert it
return $this->query("
INSERT INTO
" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_OAUTHTABLE) . "
" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_OAUTHV1TABLE) . "
(
app_username,
app_tenant,
oauth_request_token,
oauth_request_token_secret,
Expand All @@ -2286,7 +2285,6 @@ protected function _oauthRequestWriteV1($app_tenant, $token, $token_secret)
'%s',
'%s',
'%s',
'%s',
'%s'
)", $errnum, $errmsg, null, null, array( $app_tenant, $token, $token_secret, date('Y-m-d H:i:s') ));
}
Expand Down Expand Up @@ -2321,7 +2319,7 @@ protected function _oauthAccessWriteV1($request_token, $token, $token_secret, $r
// Exists... UPDATE!
return $this->query("
UPDATE
" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_OAUTHTABLE) . "
" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_OAUTHV1TABLE) . "
SET
oauth_access_token = '%s',
oauth_access_token_secret = '%s',
Expand Down Expand Up @@ -2402,9 +2400,9 @@ protected function _oauthAccessWriteV2($state, $encrypted_access_token, $encrypt
oauth_refresh_token = '%s',
oauth_access_expiry = '%s',
oauth_refresh_expiry = '%s',
access_datetime = '%s',
access_datetime = '%s',
last_access_datetime = '%s',
last_refresh_datetime = '%s'
last_refresh_datetime = '%s'
" . $more . "
WHERE
oauth_state = '%s' ", $errnum, $errmsg, null, null, $vars);
Expand All @@ -2421,7 +2419,7 @@ protected function _oauthAccessDelete($app_username, $app_tenant)
// Exists... DELETE!
$this->query("
DELETE FROM
" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_OAUTHTABLE) . "
" . $this->_mapTableName(QUICKBOOKS_DRIVER_SQL_OAUTHV1TABLE) . "
WHERE
app_username = '%s' AND
app_tenant = '%s' ", $errnum, $errmsg, null, null, array( $app_username, $app_tenant ));
Expand Down
6 changes: 3 additions & 3 deletions QuickBooks/IPP.php
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ protected function _request($Context, $type, $url, $action, $data, $post = true)
$this->_authcred['oauth_access_token_secret'])
{
// Sign the request
$OAuth = new QuickBooks_IPP_OAuth($this->_authcred['oauth_consumer_key'], $this->_authcred['oauth_consumer_secret']);
$OAuth = new QuickBooks_IPP_OAuthv1($this->_authcred['oauth_consumer_key'], $this->_authcred['oauth_consumer_secret']);

// Different than default signature method?
if ($this->_authsign)
Expand All @@ -1249,11 +1249,11 @@ protected function _request($Context, $type, $url, $action, $data, $post = true)

if ($post)
{
$action = QuickBooks_IPP_OAuth::METHOD_POST;
$action = QuickBooks_IPP_OAuthv1::METHOD_POST;
}
else
{
$action = QuickBooks_IPP_OAuth::METHOD_GET;
$action = QuickBooks_IPP_OAuthv1::METHOD_GET;
}

$signdata = null;
Expand Down
Loading

0 comments on commit 258ebd0

Please sign in to comment.