это мой код:
from intuitlib.client import AuthClient # intuit library
from quickbooks import QuickBooks # python-quickbooks package
# auth credentials to connect to the QBO account
auth_client = AuthClient(
client_id = CLIENT_ID,
client_secret = CLIENT_SECRET,
environment = ENV,
redirect_uri = REDIRECT_URI,
)
# directoryPath = parameters.directoryPath
# creating the client object to access the QBO account - if not able to connect, make 3 tries dans then stop
tries = 3
for i in range(tries):
try :
client = QuickBooks(
auth_client= auth_client,
refresh_token= REFRESH_TOKEN,
company_id= COMPANY_ID,
)
# get the refresh token returned
refresh_token_new = client.auth_client.refresh_token
# if the refresh token has changed, update it in the csv
if REFRESH_TOKEN != refresh_token_new:
print('Updating the refresh token. ' + REFRESH_TOKEN + ' --> ' + refresh_token_new)
# fieldnames list required for DictWriter
fieldnames = ['client_id','client_secret','company_id','refresh_token','env']
tempfile = NamedTemporaryFile(mode='w', delete=False)
with open('../meta.csv') as csvfile, tempfile:
reader = csv.DictReader(csvfile)
writer = csv.DictWriter(tempfile, fieldnames=fieldnames)
writer.writeheader()
values = next(reader)
values['refresh_token'] = refresh_token_new
writer.writerow(values)
# saving the contents of temp file into the main file
shutil.move(tempfile.name, '../meta.csv')
Это работает, если мой refresh_token действителен, но при его обновлении кажется, что он потерял его .... Мой объект заключается в том, что он естественно обновляет sh токен для доступа к qbo автоматически. спасибо за помощь