Может получить все счета от xero, но не смог получить всю учетную запись, столкнувшуюся с проблемой oauth_problem - PullRequest
0 голосов
/ 06 августа 2020
import os
import requests
import base64
from xero.auth import OAuth2Credentials
from xero import Xero
from xero.constants import XeroScopes
my_scope = [XeroScopes.OFFLINE_ACCESS, XeroScopes.ACCOUNTING_CONTACTS, XeroScopes.ACCOUNTING_SETTINGS, XeroScopes.ACCOUNTING_TRANSACTIONS_READ,
            XeroScopes.ACCOUNTING_TRANSACTIONS, XeroScopes.ACCOUNTING_CONTACTS_READ, XeroScopes.ACCOUNTING_SETTINGS_READ, ]

CURRENT_PATH = os.path.dirname(os.path.abspath(__file__))
REFRESH_TOKEN_PATH = os.path.join(CURRENT_PATH, "config", "refresh_token2.txt")

CLIENT_ID = 'xxxxx'
CLIENT_SECRET = 'xxxxxx'
CALLBACK_URI = 'https://xero.com/'
TENANT_ID = 'xxxxx'

credentials = OAuth2Credentials(CLIENT_ID, CLIENT_SECRET, token=TOKEN,
                                callback_uri=CALLBACK_URI, tenant_id=TENANT_ID, scope=my_scope)
XERO = Xero(credentials)
invoices = XERO.invoices.all()
print invoices
accounts = XERO.accounts.all()
print accounts

При получении всех учетных записей от xero или get_attachment_data в xero сталкивается с ошибкой oauth_problem в ответ, используя каждый раз новый токен.

...