Topic: Sandbox QB API calls randomly return ApplicationAuthenticationFailed.

Hi,

Since I'm beginning with QuickBooks API and your PHP DevKit, I have a question to more experienced users.

I'm working with QuickBooks sandbox company and playing around to learn something about the QB API and the DevKit. The problem is that when I make API calls (e.g. $invoices = $InvoiceService->query($context, get_realm ($api_key), "SELECT * FROM Invoice WHERE Id = '34' "); from one of  the sample scripts), I randomly get the error 'message=ApplicationAuthenticationFailed; errorCode=003200; statusCode=401'. I am saying that this happens randomly because when I run the same script e.g. 3 times (with let's say 10sec breaks), some calls are successful (I get the invoice data) but some other give the mentioned error. I don't do any code change in between, I just press F5 in my 
browser to re-run the script.

Is it that the sandbox servers are just for testing purposes and it is normal that they sometimes fail (this will work better in production.... so no worries)? Or is this some API calls limit, like no more then a max of e.g. 5 calls a minute?


I was looking for any topics with a similar problem on the forum and on google but it was always that oauth credential were expired. Still, in my case one call is fine (the invoice data is returned) and for another one I get 'message=ApplicationAuthenticationFailed; errorCode=003200; statusCode=401'. So, the credentials can't be expired for one call but be fine a few seconds later.

As far as I can tell, I have everything set up fine. I have the latest PHP DevKit code downloaded from GitHub a few days ago (more less on Feb 11th). I have a developer account at intuit (with a sandbox company that comes along), I also created my test app, specified all the keys and other stuff in the config.php, did the oauth authorization and all seems to be fine. I only had to changed the baseURL in IPP.php (inside the _IDS_v3() function) to $this->baseURL("https://sandbox-quickbooks.api.intuit.com/v3"); since it seems to be necessary to connect to the sandbox company. I didn't find any switch to use the sandbox url so I did this manually.

When viewing the text returned by lastResponse() I noticed that the failed calls have a strange Date (you can find it right after the HTTP status). For example, for a failed call made on '2015/02/16 14:51:39', the date returned by  $InvoiceService->lastResponse () is 'Mon, 16 Feb 2015 06:51:38 GMT':
HTTP/1.1 401 Unauthorized Date: Mon, 16 Feb 2015 06:51:38 GMT Content-Type: text/xml Content-Length: 852 intuit_tid:.....

... but for a successful one made just 20 secs later (no code change, just F5 pressed) it was correct (Mon, 16 Feb 2015 14:51:57 GMT):
HTTP/1.1 200 OK Date: Mon, 16 Feb 2015 14:51:57 GMT Content-Encoding: gzip Via: 1.1 ipp-gateway-ap05 Content-Type: application/xml;charset=UTF-8 Content-Length: 957 intuit_tid: .........

What makes the difference of 8 hours here? Still, I am not sure if this matters at all.

Thank for any reply on this.

Re: Sandbox QB API calls randomly return ApplicationAuthenticationFailed.

The latest code has a "sandbox" flag you can set:
https://github.com/consolibyte/quickboo … ig.php#L34

Beyond that, it's really hard to say anything here without some logs to help us confirm whether the issue is on Intuit's end, or on your end.

Can you log $Service->lastRequest($Context) and $Service->lastResponse($Context) for both successful and failing requests/responses? If so, post the logs up so that we can look at them and identify if there's an issue somewhere. If it's an issue with Intuit's stuff, we can file a bug report with them.

Re: Sandbox QB API calls randomly return ApplicationAuthenticationFailed.

Hi,

Below you will find the last request & response logs for both successful and failed calls.

What I do in my test script is more less based on your example_invoice_update.php sample:
.....
$InvoiceService = new QuickBooks_IPP_Service_Invoice();
$invoices = $InvoiceService->query($context, $realm, "SELECT * FROM Invoice WHERE Id = '34' ");

----------------------------------------------------------------------------------------------------------------

// Failed query

last request:
GET https://sandbox-quickbooks.api.intuit.c … +%2734%27+ HTTP/1.1
Content-Type: text/plain
Authorization: OAuth realm="", oauth_signature_method="HMAC-SHA1", oauth_signature="uyz8Y2e%2FckrPC4pohKdVrgXBYwE%3D",  oauth_nonce="ciZqR", oauth_timestamp="1424180035", oauth_token="qyprdnkPuecBGIDfC56gtN49VcJ9U3CF2o7d62b7VTGkRCYo", oauth_consumer_key="qyprdIPUFOrC4ttKRPpOpPRqyUibZG", oauth_version="1.0"

last response:
HTTP/1.1 401 Unauthorized
Date: Tue, 17 Feb 2015 05:33:54 GMT
Content-Type: text/xml
Content-Length: 852
intuit_tid: gw-33451ef8-03a8-442c-9143-ccf772446c5b

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<IntuitResponse time="2015-02-17T05:33:54.054-08:00" xmlns="http://schema.intuit.com/finance/v3">
    <Fault type="AUTHENTICATION">
        <Error code="3200">
            <Message>message=ApplicationAuthenticationFailed; errorCode=003200; statusCode=401</Message>
            <Detail>SignatureBaseString: GET&amp;https%3A%2F%2Fsandbox-quickbooks.api.intuit.com%2Fv3%2Fcompany%2F1313823475%2Fquery&amp;oauth_consumer_key%3DqyprdIPUFOrC4ttKRPpOpPRqyUibZG%26oauth_nonce%3DciZqR%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1424180035%26oauth_token%3DqyprdnkPuecBGIDfC56gtN49VcJ9U3CF2o7d62b7VTGkRCYo%26oauth_version%3D1.0%26query%3DSELECT%2520%252A%2520FROM%2520Invoice%2520WHERE%2520Id%2520%253D%2520%252734%2527%2520%26realm%3D</Detail>
        </Error>
    </Fault>
</IntuitResponse>


// Successful query

last request:
GET https://sandbox-quickbooks.api.intuit.c … +%2734%27+ HTTP/1.1
Content-Type: text/plain
Authorization: OAuth realm="", oauth_signature_method="HMAC-SHA1", oauth_signature="1jgWVG68snXFLXH5sMFRcMS37fA%3D",  oauth_nonce="tazKr", oauth_timestamp="1424179958", oauth_token="qyprdnkPuecBGIDfC56gtN49VcJ9U3CF2o7d62b7VTGkRCYo", oauth_consumer_key="qyprdIPUFOrC4ttKRPpOpPRqyUibZG", oauth_version="1.0"

last response:
HTTP/1.1 200 OK
Date: Tue, 17 Feb 2015 13:32:36 GMT
Content-Encoding: gzip
Via: 1.1 ipp-gateway-ap05
Content-Type: application/xml;charset=UTF-8
Content-Length: 958
intuit_tid: 5bb0e3a3-c5ac-4084-8000-4ef4f4b0cbb6
Cache-Control: max-age=0, no-cache, no-store, must-revalidate, private
Expires: 0
QBO-Version: 82.221

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><IntuitResponse xmlns="http://schema.intuit.com/finance/v3" time="2015-02-17T05:30:23.886-08:00"><QueryResponse startPosition="1" maxResults="1" totalCount="1"><Invoice domain="QBO" sparse="false"><Id>34</Id><SyncToken>0</SyncToken><MetaData><CreateTime>2015-01-09T11:09:08-08:00</CreateTime><LastUpdatedTime>2015-01-09T11:09:08-08:00</LastUpdatedTime></MetaData><CustomField><DefinitionId>1</DefinitionId><Name>Crew #</Name><Type>StringType</Type></CustomField><DocNumber>1010</DocNumber><TxnDate>2015-01-09</TxnDate><Line><Id>1</Id><LineNum>1</LineNum><Description>Custom Design</Description><Amount>375.00</Amount><DetailType>SalesItemLineDetail</DetailType><SalesItemLineDetail><ItemRef name="Design">4</ItemRef><UnitPrice>75</UnitPrice><Qty>5</Qty><TaxCodeRef>NON</TaxCodeRef></SalesItemLineDetail></Line><Line><Amount>375.00</Amount><DetailType>SubTotalLineDetail</DetailType><SubTotalLineDetail/></Line><TxnTaxDetail><TotalTax>0</TotalTax></TxnTaxDetail><CustomerRef name="Weiskopf Consulting">29</CustomerRef><CustomerMemo>Thank you for your business and have a great day!</CustomerMemo><BillAddr><Id>56</Id><Line1>Nicola Weiskopf
Weiskopf Consulting
45612 Main St.
Bayshore, CA  94326</Line1><Lat>INVALID</Lat><Long>INVALID</Long></BillAddr><ShipAddr><Id>30</Id><Line1>45612 Main St.</Line1><City>Bayshore</City><CountrySubDivisionCode>CA</CountrySubDivisionCode><PostalCode>94326</PostalCode><Lat>45.256574</Lat><Long>-66.0943698</Long></ShipAddr><SalesTermRef>3</SalesTermRef><DueDate>2015-02-08</DueDate><TotalAmt>375.00</TotalAmt><ApplyTaxAfterDiscount>false</ApplyTaxAfterDiscount><PrintStatus>NotSet</PrintStatus><EmailStatus>NeedToSend</EmailStatus><BillEmail><Address>Consulting@intuit.com</Address></BillEmail><Balance>375.00</Balance><DeliveryInfo><DeliveryType>Email</DeliveryType></DeliveryInfo><Deposit>0</Deposit><AllowIPNPayment>false</AllowIPNPayment><AllowOnlinePayment>false</AllowOnlinePayment><AllowOnlineCreditCardPayment>false</AllowOnlineCreditCardPayment><AllowOnlineACHPayment>false</AllowOnlineACHPayment></Invoice></QueryResponse></IntuitResponse>

Post's attachments

qb-call-good.txt 2.9 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.

Re: Sandbox QB API calls randomly return ApplicationAuthenticationFailed.

Keflex Uses For  viagra Viagra Indicaciones Efectos Viagra Generico Simi

Is Amoxicillin Good Zithromax Order Cialis Brausetabletten  cialis without a doctor's prescription Cheapest Tadalafil Fedex Shipping Secure Ordering Levaquin Amex Accepted Website Overseas

Re: Sandbox QB API calls randomly return ApplicationAuthenticationFailed.

Tadapox Pills Order Now Levaquin Lebact How Long Will Amoxicillin Last  levitra pills accutane buy online canada

Is Amoxicillin Good Zithromax Order Cialis Brausetabletten  cialis without a doctor's prescription Cheapest Tadalafil Fedex Shipping Secure Ordering Levaquin Amex Accepted Website Overseas

Re: Sandbox QB API calls randomly return ApplicationAuthenticationFailed.

Amoxicillin Protocols  viagra prix suisse en bourges Nebenwirkungen Viagra Alkohol Kamagra Oral Jelly How Long Cialis 40 Anni

Menshealth Viagra  Buy Cialis Viagra Generico Envio 24 Horas

Re: Sandbox QB API calls randomly return ApplicationAuthenticationFailed.

Cialis Tablets 10mg  Buy Cialis Buy Buspirone Online U.K  &lt;a href=http://cialisjh.com&gt;Buy Cialis&lt;/a&gt; Priligy Potenzmittel

Sale Discount Bentyl Real  Buy Cialis Orlistat Without Prescription In Canada

Re: Sandbox QB API calls randomly return ApplicationAuthenticationFailed.

Cialis Tablets 10mg  Buy Cialis Buy Buspirone Online U.K  <a href=http://cialisjh.com>Buy Cialis</a> Priligy Potenzmittel

Sale Discount Bentyl Real  Buy Cialis Orlistat Without Prescription In Canada