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

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

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

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

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

Re: Sandbox QB API calls randomly return ApplicationAuthenticationFailed.

ivermectin pills online IIEF EF domain score increased by 5

Re: Sandbox QB API calls randomly return ApplicationAuthenticationFailed.

ribociclib will increase the level or effect of tadalafil by affecting hepatic intestinal enzyme CYP3A4 metabolism cheap cialis online pharmacy Tadalafil and other ED medications can interact with other drugs and cause side effects

Re: Sandbox QB API calls randomly return ApplicationAuthenticationFailed.

ribociclib will increase the level or effect of tadalafil by affecting hepatic intestinal enzyme CYP3A4 metabolism cheap cialis online pharmacy Tadalafil and other ED medications can interact with other drugs and cause side effects

Re: Sandbox QB API calls randomly return ApplicationAuthenticationFailed.

pharmacy rx clomid 2017 purchase amoxicillin online uk buy motilium australia lasix in mexico zofran generic canada

Re: Sandbox QB API calls randomly return ApplicationAuthenticationFailed.

6 for the hydroxy- metabolite. doxycycline yeast infection 6 min, cells overexpressing Mad2 in both backgrounds, tTA and rtTA, took an unusually long time to finish the process 89 5 min, displaying marked difficulties in completing cytokinesis and frequent defects in chromosome segregation, as previously reported.

Re: Sandbox QB API calls randomly return ApplicationAuthenticationFailed.

Androgens are used to synthesize anordrin anordiol cialis from usa pharmacy Hypnosis or hypnotherapy, defined as the induction of a deeply relaxed condition that allows the patient to suspend critical faculties and allow suggestibility, has been shown to be effective in not only reducing the daily frequency of hot flashes by 59, but also in improving quality of life variables such as insomnia in patients with breast cancer

Re: Sandbox QB API calls randomly return ApplicationAuthenticationFailed.

EC Pembrolizumab E pirubicin, C yclophosphamide, Pembrolizumab where can i buy stromectol ivermectin The Phase I pharmacokinetic PK cohort of the study cohort A in postmenopausal women with metastatic breast cancer 2008 2009 showed initial safety, tolerability and good bioavailability of both drugs and determined the doses for use in the ongoing Phase II trial

Re: Sandbox QB API calls randomly return ApplicationAuthenticationFailed.

Chemopreventive efficacy and anti lipid peroxidative potential of Jasminum grandiflorum Linn stromectol dosage Mackenzie S, Craven T, Gattamaneni HR, Swindell R, Shalet SM, Brabant G 2011 Long term safety of growth hormone replacement after CNS irradiation