-
Notifications
You must be signed in to change notification settings - Fork 84
Open
Description
I read the documentation, but it's not immediately clear to me what to do.
I have put together the following code from the examples. In reality, a TAN is only required for the transactions, not for the balance, so the first TAN query never executes. I want to achieve that I have to enter a TAN only every couple of months like how it works for my banking app, but I can't understand from the documentation how to save the state.
It's probably just a minor mistake. Please help.
def kontostand(failOnError=False):
blz = "***"
login = "***"
key_id = f"{blz}.{login}"
password = keyring.get_password("fints", key_id)
if not password:
password = getpass.getpass("PIN:")
keyring.set_password("fints", key_id, password)
# Restore state
tan_data = None
if os.path.exists("tan.data"):
with open("tan.data", "rb") as f:
tan_data = f.read()
client = FinTS3PinTanClient(
blz, # Your bank's BLZ
login, # Your login name
password, # Your banking PIN
"https://fints1.atruvia.de/cgi-bin/hbciservlet",
product_id="6151256F3D4F9975B877BD4A2", # https://community.home-assistant.io/t/fints-access-needs-product-id/322464/4
from_data=tan_data,
)
minimal_interactive_cli_bootstrap(client)
with client:
# Since PSD2, a TAN might be needed for dialog initialization.
# Let's check if there is one required
if client.init_tan_response:
if failOnError:
raise Exception("A TAN is required. Run tan.py separately.")
else:
print("A TAN is required", client.init_tan_response.challenge)
tan = input("Please enter TAN:")
client.send_tan(client.init_tan_response, tan)
# Fetch accounts
accounts = client.get_sepa_accounts()
balance = client.get_balance(accounts[0])
transactions = client.get_transactions_xml(accounts[0])
if isinstance(transactions, NeedTANResponse):
print("Eine TAN wird benötigt!")
print(transactions.challenge)
tan = input("TAN:")
transactions = client.send_tan(transactions, tan)
client_data = client.deconstruct()
# Save state
with open("tan.data", "wb") as f:
f.write(client_data)
return balance.amount.amount, transactions
Metadata
Metadata
Assignees
Labels
No labels