我尝试了几种方法来连接到QuickBooks API 3,并尝试遵循doc上的步骤。但是我仍然被踩在脚下。我怎么有令牌。因为我没有从QBO收到任何信息?感谢您帮助我继续编写代码。我可以看到auth_url,但是之后不知道该怎么办...谢谢
from intuitlib.client import AuthClient
from intuitlib.enums import Scopes
from flask import Flask,redirect
import QBOConnector
#Instantiate client
auth_client = AuthClient(
QBOConnector.CLIENT_ID,
QBOConnector.CLIENT_SECRET,
QBOConnector.REDIRECT_URI,
QBOConnector.environment, # “sandbox” or “production”
)
# Prepare scopes
scopes = [
Scopes.ACCOUNTING,
]
# Get authorization URL
auth_url = auth_client.get_authorization_url(scopes)
print(auth_url)
#Using standard redirect
test = redirect(auth_url)
我的目标是连接并具有refresh_token和realm_ID
我找到一种保存方式:
REDIRECT_URI = 'https://developer.intuit.com/v2/OAuth2Playground/RedirectUrl' # not using the redirection at the moment
ENV = QBOConnector.PROD_environment
REFRESH_TOKEN = QBOConnector.PROD_TOKEN # Refresh token needs to be added here (which will be generated from https://developer.intuit.com/app/developer/playground)
COMPANY_ID = QBOConnector.PROD_COMPANY_ID #id of the company that we use in the example
# auth credentials to connect to the QBO account
auth_client = AuthClient(
client_id = QBOConnector.PROD_CLIENT_ID,
client_secret = QBOConnector.PROD_CLIENT_SECRET,
environment = ENV,
redirect_uri = REDIRECT_URI,
)
# creating the client object to access the QBO account
client = QuickBooks(
auth_client= auth_client,
refresh_token= REFRESH_TOKEN,
company_id= COMPANY_ID,
)
# retrieving all customers for the above client object
customers = Customer.all(qb=client)
# printing all customer names on the console/shell
for customer in customers:
print (customer)
# request authorization
auth_header = 'Bearer {0}'.format(auth_client.access_token)
headers = {
'Authorization': auth_header,
'Accept': 'application/json'
}
base_url = 'https://quickbooks.api.intuit.com'
# --- trial Balance
url = '{0}//v3/company/{1}/reports/TrialBalance?end_date=2019-09-30&minorversion=4'.format(base_url,
QBOConnector.PROD_COMPANY_ID)
response = requests.get(url, headers=headers)
例如,这允许访问试用余额报告。