Reputation: 117
I recently have a Django project that requires me to pull data from Quickbooks Online and then storing it in MySQL database for later uses.
Following a tutorial that I found in https://github.com/sidecars/python-quickbooks, I was able to get my access and refresh token using
quickbooks-cli -p 8000 <Client ID> <Client Secret> 2
Here come a few questions I like to ask:
Thanks in advance.
Upvotes: 0
Views: 1157
Reputation: 27982
Is there any implications setting http://localhost:8000 as one of my Redirect URIs in the Intuit Developer's Key section?
You won't be able to go live with that set (Intuit won't let you). But for development, it's fine.
Eventually you should swap that out for your production URL.
What should I do with the access and refresh token?
Here's what the docs you linked to them say:
Also, you'll need to use the access token to access data via the API. From the docs:
session_manager = Oauth2SessionManager(
client_id=realm_id,
client_secret=CLIENT_SECRET,
access_token=AUTH2_ACCESS_TOKEN,
)
from quickbooks import QuickBooks
client = QuickBooks(
sandbox=True,
session_manager=session_manager,
company_id=realm_id
)
from quickbooks.objects.customer import Customer
customers = Customer.all(qb=client)
This is shown in the docs here: https://github.com/sidecars/python-quickbooks#accessing-the-api
I noticed there is a duration before the access and refresh token expires, so does it mean I have to change them every once in a while?
You have to refresh them, yes:
session_manager = Oauth2SessionManager(
client_id=QUICKBOOKS_CLIENT_ID,
client_secret=QUICKBOOKS_CLIENT_SECRET,
base_url=callback_url,
)
session_manager.refresh_access_token()
From the docs here: https://github.com/sidecars/python-quickbooks#refreshing-access-token
Upvotes: 1