Skip to content

401 Client Error: for url: https://api.traderepublic.com/api/v1/auth/web/session #335

@brot

Description

@brot

Description of the bug
I'm using the latest version of pytr (0.4.8) and with this version the WAF token seems to work now, but after I typed in my code I received on my phone, pytr crashes with "401 Client Error: for url: https://api.traderepublic.com/api/v1/auth/web/session".

To Reproduce
Running pytr via uvx:
uvx pytr dl_docs --last_days 20 ~/Downloads/pytr

Expected behavior
pytr should download documents and transactions

Error log

21:32:43 Using credentials from file ~/.pytr/credentials. Phone: +*************, PIN: ****
21:32:43 Trying to resume websession...
21:32:43 Resuming websession failed.
21:32:43 Initiating web login...
21:32:43 Retrieving AWS WAF token using Playwright...
Enter the code you received to your mobile app as a notification.
Enter nothing if you want to receive the (same) code as SMS. (Countdown: 31)
Code: ****
21:32:55 Logged in.
Traceback (most recent call last):
  File "/Users/bernd/.cache/uv/archive-v0/c90AGJG8zSi6JEP5ih6g3/bin/pytr", line 12, in <module>
    sys.exit(main())
             ~~~~^^
  File "/Users/bernd/.cache/uv/archive-v0/c90AGJG8zSi6JEP5ih6g3/lib/python3.14/site-packages/pytr/main.py", line 477, in main
    login(
    ~~~~~^
        phone_no=args.phone_no,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<2 lines>...
        waf_token=args.waf_token,
        ^^^^^^^^^^^^^^^^^^^^^^^^^
    ),
    ^
  File "/Users/bernd/.cache/uv/archive-v0/c90AGJG8zSi6JEP5ih6g3/lib/python3.14/site-packages/pytr/account.py", line 82, in login
    log.debug(get_settings(tr))
              ~~~~~~~~~~~~^^^^
  File "/Users/bernd/.cache/uv/archive-v0/c90AGJG8zSi6JEP5ih6g3/lib/python3.14/site-packages/pytr/account.py", line 13, in get_settings
    formatted_json = json.dumps(tr.settings(), indent=2)
                                ~~~~~~~~~~~^^
  File "/Users/bernd/.cache/uv/archive-v0/c90AGJG8zSi6JEP5ih6g3/lib/python3.14/site-packages/pytr/api.py", line 778, in settings
    r = self._web_request("/api/v2/auth/account")
  File "/Users/bernd/.cache/uv/archive-v0/c90AGJG8zSi6JEP5ih6g3/lib/python3.14/site-packages/pytr/api.py", line 281, in _web_request
    r.raise_for_status()
    ~~~~~~~~~~~~~~~~~~^^
  File "/Users/bernd/.cache/uv/archive-v0/c90AGJG8zSi6JEP5ih6g3/lib/python3.14/site-packages/requests/models.py", line 1028, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error:  for url: https://api.traderepublic.com/api/v1/auth/web/session

Environment

  • OS: MacOS
  • pytr version: 0.4.8

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions