MoritzR / fints2ledger

A tool for downloading transactions from FinTS banking APIs and sorting them into a ledger journal
MIT License
26 stars 8 forks source link

Exception: Refusing to use PIN after block #38

Open varac opened 10 months ago

varac commented 10 months ago

When I don't log into the web interface of my bank for a while, it requires that I use a TAN in order to authenticate myself. When I run fints2ledger before using a TAN in the web interface I get this exception:

Dialog response: 9050 - Die Nachricht enthält Fehler.
Dialog response: 9800 - Dialog abgebrochen
Dialog response: 9340 - Auftrag abgelehnt.
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/fints/client.py", line 453, in get_sepa_accounts
    return self._send_with_possible_retry(dialog, seg, self._get_sepa_accounts)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/fints/client.py", line 1243, in _send_with_possible_retry
    response = dialog.send(command_seg)
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/fints/dialog.py", line 156, in send
    self.client.process_response_message(self, response, internal_send=internal_send)
  File "/usr/lib/python3.11/site-packages/fints/client.py", line 230, in process_response_message
    self._process_response(dialog, None, response)
  File "/usr/lib/python3.11/site-packages/fints/client.py", line 1303, in _process_response
    raise FinTSClientPINError("Error during dialog initialization, PIN wrong?")
fints.exceptions.FinTSClientPINError: Error during dialog initialization, PIN wrong?

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/varac/bin/download/data/pyfints.py", line 74, in <module>
    main()
  File "/home/varac/bin/download/data/pyfints.py", line 55, in main
    transactions = retrieve_transactions(
                   ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/varac/bin/download/data/pyfints.py", line 10, in retrieve_transactions
    return TRetriever(client, selected_account).get_hbci_transactions(start, end)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/varac/bin/download/data/pyfints.py", line 19, in get_hbci_transactions
    accounts = self.client.get_sepa_accounts()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/fints/client.py", line 452, in get_sepa_accounts
    with self._get_dialog() as dialog:
  File "/usr/lib/python3.11/site-packages/fints/dialog.py", line 45, in __exit__
    self.end()
  File "/usr/lib/python3.11/site-packages/fints/dialog.py", line 112, in end
    response = self.send(HKEND1(self.dialog_id), internal_send=True)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/fints/dialog.py", line 131, in send
    self.finish_message(message)
  File "/usr/lib/python3.11/site-packages/fints/dialog.py", line 178, in finish_message
    auth_mech.sign_commit(message)
  File "/usr/lib/python3.11/site-packages/fints/security.py", line 157, in sign_commit
    user_defined_signature=UserDefinedSignature(
                           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/fints/types.py", line 361, in __init__
    setattr(self, k, v)
  File "/usr/lib/python3.11/site-packages/fints/types.py", line 46, in __set__
    value_ = self._parse_value(value)
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/fints/fields.py", line 299, in _parse_value
    return Password(value)
           ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/fints/utils.py", line 260, in __str__
    raise Exception("Refusing to use PIN after block")
Exception: Refusing to use PIN after block

fints2ledger: PyFintsError "Failed to get FinTS transactions, check the message above."

It would be nice to catch this exception.