-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problems with refresh_token() #16
Comments
Hi Martin, thanks for reporting this. I could reproduce the issue with the code you provided for P_TAN, and there seems to be an issue with the session import. Without exporting and importing refreshing works flawlessly but importing the session from a file causes the token refresh to break subsequent request (401). Unfortunately, I haven't found out yet what causes that behavior though :( |
Hi Alex, thanks for confirming reproducibility. I tried another lib and had the same problem. Could solve it by starting a daemon-thread in main.py for periodically refreshing the token. I have abandoned using the comdirect-API all together, because some endpoints seem to be permanently out of order, but it was a delight to read your code. Thanks again for sharing! |
Hi Alex, I've traced this a bit and compared the HTTP requests for refresh_token() made by a fresh session and an imported one. Both looked fine, but the "Authorization: Bearer" header looked quite different: Fresh session: Imported session: These values come from the access token. I didn't dig into this any further, though. Hope this helps debugging. |
A further note on this: when I pickle and unpickle the whole ComdirectClient object, refresh_token() works fine for it. So that's a workaround for me. But thanks for your great work here anyway! |
Hi Michael, thanks for sharing your findings, this is quite helpful. I will investigate this a bit more once I find the time. |
Hi Alex, I am just looking for an api, that I can use to trade with comdirect. I saw this issue and would like to know if you had a further look on it. As I understood with the workaround of refreshing ever x min I could use your api anyway. Thanks for your work and your time on this topic. |
I fixed the problem in my pull-request from today. Took me a while to pinpoint the problem... |
Hello, thanks so much for sharing this! It works really well so far, just using refresh_token() gives huzzles. After calling it, it might be that one or two following other API-calls still work, but then get a "401 - unauthorized" and need to re-authenticate with an M_TAN.
Your code looks perfectly fine and is following the spec, maybe it only works with P_TAN?
This is what I do, to test it:
I have an 'ini.py' file where I do the TAN-dance once and export the session:
And then run it of the command-line
python3 ini.py
, which works fine.Then I import the session in another file called 'main.js' and do some API-calls:
I can execute main.py flawlessly for the next ten minutes, before the token expires.
However whenever I add the line
client.refresh_token()
to main.py, the next one or two calls work, but then get 401.The text was updated successfully, but these errors were encountered: