Search code examples
phpoauthintuit-partner-platform

Quickbooks API access token signature_invalid


I am having trouble getting an access token for the Quickbooks API. I successfully get a request token and user verification, but when I run this code:

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, 'https://oauth.intuit.com/oauth/v1/get_access_token?oauth_consumer_key=qyprdNDNZ9hEhZgwZBBia6ZDkwpRtP&oauth_nonce=HUPXw&oauth_signature=raVWgofhFJpAtES9e0mqlxe0I2k%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1384812231&oauth_token=qyprdWLEO99zeQjkz3C75A6bJxLYMgOESy9PQDS4IIUZ9fY3&oauth_verifier=7unnxvg&oauth_version=1.0');
$r = curl_exec($ch);
print $r;

... it prints "oauth_problem=signature_invalid". What am I doing wrong?


Solution

  • You didn't really post enough code for us to tell you what's going on. My bet would be that you aren't generating your OAuth signature or request correctly.

    Can you post the rest of your code?

    OAuth is a pretty non-trivial topic - you might consider using one of the existing PHP DevKits for QuickBooks which does all of this hard work (and a lot of other hard work) for you.

    Using the QuickBooks PHP DevKit linked above, authorizing/getting these tokens is as simple as:

    <?php
    
    /**
     * Require the QuickBooks library
     */
    require_once dirname(__FILE__) . '/../../QuickBooks.php';
    
    /**
     * Require some IPP/OAuth configuration data
     */
    require_once dirname(__FILE__) . '/config.php';
    
    // Try to handle the OAuth request 
    if ($IntuitAnywhere->handle($the_username, $the_tenant))
    {
            ; // The user has been connected, and will be redirected to $that_url automatically. 
    }
    else
    {
            // If this happens, something went wrong with the OAuth handshake
            die('Oh no, something bad happened: ' . $IntuitAnywhere->errorNumber() . ': ' . $IntuitAnywhere->errorMessage());
    }
    

    A good place to start is in the example QuickBooks PHP app and following the PHP + Intuit Anywhere quick-start guide.