问题
Zapier has been a handy way to connect to API's like quickbooks. However there is very little documentation on how to set this up, which caused me to spend weeks figuring it out (hopefully for you this will help!). This is a Q&A post, however if anyone has input that will improve this information please feel free to share here.
If you find yourself in a situation like mine and you are looking on how to also make an 'action' or 'trigger' for quickbooks just leave a comment and I can work on a tutorial for those as well.
If I have posted this in the wrong format for Stack Overflow please let me know and I will correct that or move it to a blog.
Depending on how things go I may end up submitting my zap for public use (My zap finds estimates by their ID and returns everything, useful for when you have a web-hook on Quickbooks). Anyway, all the information presented in this post is for the OAuth2 setup.
Here is the documentation I used:
API OAuth 2.0
Playground
Question: How do I connect Quickbooks API to a custom app in Zapier Developer with OAuth2?
回答1:
To start this answer assumes you have a Quickbooks and Zapier dev account. It also assumes you have begun to setup your first Zap and are now working on authentication.
In Zapier Dev, choose Authentication tab and select OAuth2
Leave "Configure your Fields" blank and press continue
In "Enter your Application Credentials" enter your credintials from your Intuit keys page
Now in "Add OAuth v2 Endpoint Configuration" enter the following as shown for the Authorization URL section:
Next define your scope, I used com.intuit.quickbooks.accounting openid email profile
We also have to get the "Access Token Request", set it up like this:
Finally add the refresh request:
Set "Automatically Refresh Token" to checked.
Now, the next part is custom, but I set up my test request to a random query (you can do the same if you want)
const options = {
url: 'https://sandbox-quickbooks.api.intuit.com/v3/company/ENTERYOURREALMID/query?query=select*from Invoice&minorversion=38',
method: 'GET',
headers: {
'Authorization': `Bearer ${bundle.authData.access_token}`,
'content-type': 'application/x-www-form-urlencoded',
'accept': 'application/json'
},
params: {
},
body: {
}
}
return z.request(options)
.then((response) => {
response.throwForStatus();
const results = z.JSON.parse(response.content);
// You can do any parsing you need for results here before returning them
return results;
});
Just toss in your RealmID in the http link (you can get the REALMID by clicking myaccount in Quickbooks, this is the same as Company ID).
Once you connect and run it should enter the HTTP Headers for you. If not, then for all sections they are same:
content-type: application/x-www-form-urlencoded
accept: application/json
That's it! Connect your account and you should be good to go!
NOTES:
-Quickbooks will require a refresh each 100 days.
-Remember that you must use backticks ` over single quotes ' if you are using a Zapier variable.
来源:https://stackoverflow.com/questions/57994388/qa-how-to-setup-quickbooks-oauth2-on-zapier