无法从 QBO 上传报告
Can t upload reports from QBO
我正在尝试使用 python 获取 QBO 报告 我遇到了这个错误:
intuitlib.exceptions.AuthClientError:HTTP状态400,错误信息:b'{"error_description":"The token is not an authorization code: actualTokenType=RefreshToken","error":"invalid_grant"}',
我试图更改授权码以刷新令牌,但它不起作用。我能够连接到 QBO 以获取发票等对象,...
from intuitlib.client import AuthClient
from intuitlib.enums import Scopes
import requests
import QBOConnector
REDIRECT_URI = 'https://developer.intuit.com/v2/OAuth2Playground/RedirectUrl'
auth_client = AuthClient(QBOConnector.CLIENT_ID, QBOConnector.CLIENT_SECRET, REDIRECT_URI, QBOConnector.environment )
url = auth_client.get_authorization_url([Scopes.ACCOUNTING])
auth_client.get_bearer_token(QBOConnector.TOKEN, realm_id=QBOConnector.CLIENT_ID)
auth_header = 'Bearer {0}'.format(auth_client.access_token)
headers = {
'Authorization': auth_header,
'Accept': 'application/json'
}
base_url = 'https://sandbox-quickbooks.api.intuit.com'
url = '{0}//v3/company/{1}/query?query=ProfitAndLoss?&minorversion=4'.format(base_url,auth_client.realm_id)
print('Url')
print(url)
response = requests.get(url, headers=headers)
打印特定时间段的概况和损失报告
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)
我正在尝试使用 python 获取 QBO 报告 我遇到了这个错误:
intuitlib.exceptions.AuthClientError:HTTP状态400,错误信息:b'{"error_description":"The token is not an authorization code: actualTokenType=RefreshToken","error":"invalid_grant"}',
我试图更改授权码以刷新令牌,但它不起作用。我能够连接到 QBO 以获取发票等对象,...
from intuitlib.client import AuthClient
from intuitlib.enums import Scopes
import requests
import QBOConnector
REDIRECT_URI = 'https://developer.intuit.com/v2/OAuth2Playground/RedirectUrl'
auth_client = AuthClient(QBOConnector.CLIENT_ID, QBOConnector.CLIENT_SECRET, REDIRECT_URI, QBOConnector.environment )
url = auth_client.get_authorization_url([Scopes.ACCOUNTING])
auth_client.get_bearer_token(QBOConnector.TOKEN, realm_id=QBOConnector.CLIENT_ID)
auth_header = 'Bearer {0}'.format(auth_client.access_token)
headers = {
'Authorization': auth_header,
'Accept': 'application/json'
}
base_url = 'https://sandbox-quickbooks.api.intuit.com'
url = '{0}//v3/company/{1}/query?query=ProfitAndLoss?&minorversion=4'.format(base_url,auth_client.realm_id)
print('Url')
print(url)
response = requests.get(url, headers=headers)
打印特定时间段的概况和损失报告
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)