Skip to content

Commit

Permalink
Work on consolibyte#181, auth and HTTP requests via OAuth2 actually w…
Browse files Browse the repository at this point in the history
…orking now.
  • Loading branch information
keith-chargeover committed May 8, 2019
1 parent 3b5fd6a commit c3e28c2
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 104 deletions.
100 changes: 1 addition & 99 deletions QuickBooks/IPP.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,72 +301,6 @@ public function __construct($dsn = null, $encryption_key = null, $config = array
//$this->flavor(QuickBooks_IPP_IDS::FLAVOR_DESKTOP);
}

/**
* Authenticate to the IPP web service
*
* IMPORTANT NOTE:
* Intuit disallows this method within live applications! You can use it to
* test your application, but when you go live you'll need to instead use
* a SAML gateway for single-sign-on authentication. Take a look at the
* QuickBooks_IPP_Federator class for a working SAML gateway.
*
* @param string $username
* @param string $password
* @param string $token
* @return boolean
*/
public function authenticate($username, $password, $token)
{
$this->_username = $username;
$this->_password = $password;
$this->_token = $token;

$url = 'https://workplace.intuit.com/db/main?act=API_Authenticate';
$action = 'API_Authenticate';

$xml = '<?xml version="1.0" encoding="UTF-8" ?>
<qdbapi>
<username>' . $username . '</username>
<password>' . $password . '</password>
<apptoken>' . $token . '</apptoken>
</qdbapi>';

$Context = null;
$response = $this->_request($Context, QuickBooks_IPP::REQUEST_IPP, $url, $action, $xml);

if (!$this->_hasErrors($response) and
$ticket = QuickBooks_XML::extractTagContents('ticket', $response))
{
$this->_ticket = $ticket;

$cookies = array(
'scache',
'ptest',
'stest',
'luid',
'TICKET',
'qbn.ticket',
'qbn.tkt',
'qbn.authid',
'qbn.gauthid',
'qbn.agentid',
'iamValidationTime'
);

foreach ($cookies as $cookie)
{
if ($value = $this->_extractCookie($cookie, $response))
{
$this->_cookies[$cookie] = $value;
}
}

return new QuickBooks_IPP_Context($this, $ticket, $token);
}

return false;
}

/**
* Create a Context object (used for session management) for a given ticket and token
*
Expand Down Expand Up @@ -448,28 +382,6 @@ public function password()
return $this->_password;
}

/*
public function ticket($ticket = null)
{
if ($ticket)
{
$this->_ticket = $ticket;
}
return $this->_ticket;
}
public function token($token = null)
{
if ($token)
{
$this->_token = $token;
}
return $this->_token;
}
*/

/**
*
*
Expand Down Expand Up @@ -520,12 +432,11 @@ public function authcreds()
* @param string $authmode The new auth mode
* @return string The currently set auth mode
*/
public function authMode($authmode = null, $authuser = null, $authcred = null, $authsign = null, $authkey = null)
public function authMode($authmode = null, $authcred = null, $authsign = null, $authkey = null)
{
if ($authmode)
{
$this->_authmode = $authmode;
$this->_authuser = $authuser;
$this->_authcred = $authcred;

$this->_authsign = $authsign;
Expand Down Expand Up @@ -1528,8 +1439,6 @@ protected function _request($Context, $type, $url, $action, $data, $post = true)
// Authorization stuff
if ($this->_authmode == QuickBooks_IPP::AUTHMODE_OAUTHV2)
{
print_r($this);

if ($this->_authcred['oauth_access_token'])
{
$headers['Authorization'] = 'Bearer ' . $this->_authcred['oauth_access_token'];
Expand Down Expand Up @@ -1640,13 +1549,6 @@ protected function _request($Context, $type, $url, $action, $data, $post = true)
$headers['Cookie'] = $this->cookies(true);
}

print('AUTH: ' . $this->_authmode . ']');
print_r($headers);
exit;

//$url = str_replace("SELECT * FROM customer", "SELECT+*+FROM+customer", $url);
//print('NEW URL [' . $url . ']' . "\n\n");

// Our HTTP requestor
$HTTP = new QuickBooks_HTTP($url);

Expand Down
3 changes: 1 addition & 2 deletions docs/partner_platform/example_app_ipp_v3/config_oauthv1.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@

// Tell the framework to load some data from the OAuth store
$IPP->authMode(
QuickBooks_IPP::AUTHMODE_OAUTH,
$the_username,
QuickBooks_IPP::AUTHMODE_OAUTHV1,
$creds);

if ($sandbox)
Expand Down
3 changes: 0 additions & 3 deletions docs/partner_platform/example_app_ipp_v3/config_oauthv2.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,6 @@
// Get some company info
$CompanyInfoService = new QuickBooks_IPP_Service_CompanyInfo();
$quickbooks_CompanyInfo = $CompanyInfoService->get($Context, $realm);

print($CompanyInfoService->lastRequest());
print($CompanyInfoService->lastResponse());
}
else
{
Expand Down

0 comments on commit c3e28c2

Please sign in to comment.