grindsa/dkb-robo

LinkNotFoundError when trying to log in

schlagenhauf opened this issue · 6 comments

I tried to get some / any data with the following script

#!/usr/bin/env python

import sys
from dkb_robo import DKBRobo
from pprint import pprint

def main():
    argv = sys.argv
    dkb_user = argv[1]
    dkb_password = input('Password: ')
    tan_insert = True 
    debug = True
    with DKBRobo(dkb_user, dkb_password, tan_insert, debug) as dkb:
        pprint(dkb.account_dic)

if __name__ == '__main__':
    main()

and i get

2020-07-20 22:09:27.874086: DKBRobo.login()

2020-07-20 22:09:27.874139: DKBRobo.new_instance()

2020-07-20 22:09:29.219896: DKBRobo.ctan_check()

Traceback (most recent call last):
  File "[...]/bankstats_cli", line 11, in <module>
    load_entry_point('Bankstats', 'console_scripts', 'bankstats_cli')()
  File "[...]cli.py", line 14, in main
    with DKBRobo(dkb_user, dkb_password, tan_insert, debug) as dkb:
  File "[...]/venv/lib/python3.8/site-packages/dkb_robo/dkb_robo.py", line 65, in __enter__
    self.login()
  File "[...]/venv/lib/python3.8/site-packages/dkb_robo/dkb_robo.py", line 493, in login
    login_confirmed = self.ctan_check(soup)
  File "[...]/venv/lib/python3.8/site-packages/dkb_robo/dkb_robo.py", line 508, in ctan_check
    self.dkb_br.select_form('form[name="confirmForm"]')
  File "[...]/venv/lib/python3.8/site-packages/mechanicalsoup/stateful_browser.py", line 207, in select_form
    raise LinkNotFoundError()
mechanicalsoup.utils.LinkNotFoundError

Some time (~ 10s) later i get a push notification via TAN2GO.

Am i missing something?

It seems that the html form to insert the TAN cannot be found. Can you please manually login (via regular browser) to ensure that your account has not been locked?

I found something interesting.

Short answer is: I still can log in via browser, but the log in steps seem to change slightly.


When i tried to log in via browser, after i filled in my credentials i didn't get the TAN field right away but this:

screenshot_dkb_tan1

After clicking "Anmeldung bestaetigen" i got the actual dialog with the TAN field:

screenshot_dkb_tan2

and could log in successfully. Interestingly, when logging off an on again right away, the TAN dialog appears immediately. However the script still fails with the same error. Also, after trying the script again, the dkb page shows the "Anmeldung bestaetigen" page in the browser again.

My interpretation would be:

  • Using dkb_robo causes the dkb page to show an extra page without TAN field
  • This causes the error in question
  • The solution would either be to avoid triggering the extra page (seems fragile) or handling a possible extra page before the actual TAN field.

What do you think?

Thx for the information. I think we are getting closer.

The device you are using to get the TAN is NOT listed as trusted device ("Vertrauenswürdiges Gerät") right?

Correct. I'm using the TAN2GO app, not the full DKB app.

I was able to replicate the issue and pushed some changes d40200e into the devel branch. Give it a try and let me know if it works.

/G

Awesome, works for me.

Thanks for the quick response!