Search code examples
c#quickbooksquickbooks-online

Quickbooks Online integration c#


My company uses QuickBooks Online, and I would like to write some c# scripts that retrieve very basic information like a list of customers and list of invoices from the QuickBooks Online subscription.

I would also like to submit invoices and payments.

I have created a QuickBooks IPP account (at developer.intuit.com).

I am able to authenticate myself (OAuth) just fine. My questions are:

1) Do I need to authenticate myself every time I wish to connect to QBO IPP (to retrieve a list of customers, submit an invoice, etc.)? Or can my app authenticate itself once & stay 'connected' for months?

2) Is there any sample code to do basic things such as obtain a list of customers, submit an invoice, etc.? I downloaded the sample MVC app from this link

And it was quite helpful - but when I try to get some of the code to work, I just get errors - which leads me to my first question - can I authenticate myself ONCE and use those tokens (appToken, and appTokenSecret) many times in order to perform simple tasks (obtain customer list), or do I have to authenticate myself every time?

Thank you.


Solution

  • Re - 1) Do I need to authenticate myself every time I wish to connect to QBO IPP (to retrieve a list of customers, submit an invoice, etc.)? Or can my app authenticate itself once & stay 'connected' for months?

    Please find below steps to get OAuth tokens using which you can make API call against your QBO account. If you create an app in appcenter, you'll get consumerKey and consumerSecret. https://developer.intuit.com/Application/Create/IA

    Using the above two tokens, you can generate accessToken and accessSecret from the OAuthPlayground. https://appcenter.intuit.com/Playground/OAuth/IA PN - After completing C2QB(OAuth) flow, you should use 'App Menu API Test.' option which will show you accessToken and accessSecret.

    These tokens are valid for 180 days (at max). When these tokens are more than 150 days old (and <180 days), you can make Reconnect API call to revalidate those again. Ref https://developer.intuit.com/docs/0050_quickbooks_api/0020_authentication_and_authorization/oauth_management_api#Reconnect

    So you can always persist these tokens and reuse it.

    To let end users connect their QB data with you SaaS app, you need to implement a wizard called 'Connect to Quickbook'. Using 3-legged Oauth your app will be able to capture the acessToken and acessSecret corresponding to the end-user's qbo account. Ref - https://developer.intuit.com/docs/0100_accounting/0060_authentication_and_authorization/connect_from_within_your_app#7._Add_the_Connect_to_QuickBooks_button

    Re - 2) Is there any sample code to do basic things such as obtain a list of customers, submit an invoice, etc.?

    Please refer - https://developer.intuit.com/docs/0100_accounting/0500_developer_kits/0150_ipp_.net_devkit_3.0/0002_synchronous_calls#/Data_Services_API

    and how to add invoice or sales receipt quickbooks rest api v3.0