QuickBooks/IPP/Federator.php
public function connectOAuth($provider, $token, $pem_key, $encryption_key, $app_username, $app_tenant, $auth_id_pseudonym, $realm_id_pseudonym, $realm, $flavor)
	{
		if (!$this->_driver)
		{
			$this->_log('Could not connect to OAuth, no DRIVER storage instance.');
			return false;
		}
		
		$url = QuickBooks_IPP_Federator::URL_OAUTH;
		
		// First we need to push the request data into the OAuth storage
		$this->_driver->oauthRequestWrite(
			$app_username, 
			$app_tenant, 
			$auth_id_pseudonym, 
			$realm_id_pseudonym);
		
		$params = array(
			'xoauth_service_provider_id' => $provider,
			'xoauth_auth_id_pseudonym' => $auth_id_pseudonym, 
			'xoauth_realm_id_pseudonym' => $realm_id_pseudonym,
			);
		
		// Create our OAuth instance class
		$OAuth = new QuickBooks_IPP_OAuth(
			$token,		// The "consumer key" in this case is our application token 
			'');		// There is no consumer secret 
		
		$OAuth->signature(QuickBooks_IPP_OAuth::SIGNATURE_RSA, $pem_key);
		
		// Sign the request
		$sign = $OAuth->sign(QuickBooks_IPP_OAuth::METHOD_GET, $url, null, null, $params);
		
		// Now make our HTTP request to get the OAuth tokens 
		$HTTP = new QuickBooks_HTTP($sign[2]);
		
		$HTTP->useDebugMode($this->_debug);
		
		$data = $HTTP->GET();
		
		$this->_log('OAuth HTTP request: [' . $HTTP->lastRequest() . ']');
		$this->_log('OAuth HTTP response: [' . $HTTP->lastResponse() . ']');
		
		if ($data)
		{
			$tmp = array();
			parse_str($data, $tmp);
			
			if (!empty($tmp['oauth_token']) and 
				!empty($tmp['oauth_token_secret']))
			{
				// Store the OAuth tokens  
				
				$this->_log('Storing OAuth tokens...');
				
				return $this->_driver->oauthAccessWrite(
					$encryption_key, 
					$auth_id_pseudonym, 
					$tmp['oauth_token'], 
					$tmp['oauth_token_secret'], 
					$realm, 
					$flavor);
			}
		}
		
		return false;
	}
public function connectOAuth($provider, $token, $pem_key, $encryption_key, $app_username, $app_tenant, $auth_id_pseudonym, $realm_id_pseudonym, $realm, $flavor)
	{
		if (!$this->_driver)
		{
			$this->_log('Could not connect to OAuth, no DRIVER storage instance.');
			return false;
		}
		
		$url = QuickBooks_IPP_Federator::URL_OAUTH;
		
		// First we need to push the request data into the OAuth storage
		$this->_driver->oauthRequestWrite(
			$app_username, 
			$app_tenant, 
			$auth_id_pseudonym, 
			$realm_id_pseudonym);
		
		$params = array(
			'xoauth_service_provider_id' => $provider,
			'xoauth_auth_id_pseudonym' => $auth_id_pseudonym, 
			'xoauth_realm_id_pseudonym' => $realm_id_pseudonym,
			);
		
		// Create our OAuth instance class
		$OAuth = new QuickBooks_IPP_OAuth(
			$token,		// The "consumer key" in this case is our application token 
			'');		// There is no consumer secret 
		
		$OAuth->signature(QuickBooks_IPP_OAuth::SIGNATURE_RSA, $pem_key);
		
		// Sign the request
		$sign = $OAuth->sign(QuickBooks_IPP_OAuth::METHOD_GET, $url, null, null, $params);
		
		// Now make our HTTP request to get the OAuth tokens 
		$HTTP = new QuickBooks_HTTP($sign[2]);
		
		$HTTP->useDebugMode($this->_debug);
		
		$data = $HTTP->GET();
		
		$this->_log('OAuth HTTP request: [' . $HTTP->lastRequest() . ']');
		$this->_log('OAuth HTTP response: [' . $HTTP->lastResponse() . ']');
		
		if ($data)
		{
			$tmp = array();
			parse_str($data, $tmp);
			
			if (!empty($tmp['oauth_token']) and 
				!empty($tmp['oauth_token_secret']))
			{
				// Store the OAuth tokens  
				
				$this->_log('Storing OAuth tokens...');
				
				return $this->_driver->oauthAccessWrite(
					$encryption_key, 
					$auth_id_pseudonym, 
					$tmp['oauth_token'], 
					$tmp['oauth_token_secret'], 
					$realm, 
					$flavor);
			}
		}
		
		return false;
	}
Fetch OAuth tokens with the data provided to you in the SAML request

Federated applications can use OAuth for unattended access to IDS data.
(i.e. access data even if the user isn't logged in) Before you start
using this, you have to make sure Intuit onboards you for OAuth access.

@param string $provider					Your federated provider id (Intuit should have given you this)
@param string $token						Your application token
@param string $key						The full path to your .pem file (e.g. /path/to/file.pem)
@param string $user						The username or user ID of the authenticating user
@param string $tenant					The tenant ID of the authenticating user
@param string $auth_id_pseudonym			The Auth ID Pseudonym extracted from the SAML message
@param string $realm_id_pseudonym		The Realm ID Pseudonym extracted from the SAML message
@return boolean