How to validate QuickBooks's connection?

时间:2016-08-30 04:24:23

标签: c# quickbooks quickbooks-online

I have been integrating QuickBooks's API to my web application. I made requests to get tokens (both request token and secret token), I stored them to database. So, how can I validate connection at second time or more, I mean because I had tokens in database, so I don't want to re-authorize to get other new tokens. I tried to find solutions to resolve it, but there's no anything. Please give me some methods or advices to get it done. Thank you very much!

1 个答案:

答案 0 :(得分:1)

  

那么,如何在第二次或更多时间验证连接,

您可以通过对v3服务进行查询来验证令牌,并检查您是否收到200 OK401 Unauthorized响应。

伪代码看起来像这样:

function am_i_connected_to_quickbooks()
{
   if (you have tokens stored in your database)
   {
       results = do_qb_query("SELECT * FROM Customer MAXRESULTS 1")
       if (you got a 200 OK back from Intuit)
       {
           // You are connected, and the tokens are still valid/have not been revoked
           return true
       }
   }

   // You don't have tokens, or your tokens are invalid (revoked, expired, incorrect, etc.)
   return false
}