Skip to content

Error when login with username+password+mfa_secret #67

@wahackr

Description

@wahackr

Where to find the mfa_secret? Is that code after from FT website after enabled MFA?

Logging in...
Traceback (most recent call last):
  File "/home/wah/Workspaces/Firstrade-Profilio-Analysis/main.py", line 11, in <module>
    main()
    ~~~~^^
  File "/home/wah/Workspaces/Firstrade-Profilio-Analysis/main.py", line 6, in main
    ft_ss = login(username, password, email, mfa_secret)
  File "/home/wah/Workspaces/Firstrade-Profilio-Analysis/libs/firstrade/client.py", line 32, in login
    need_code = ft_ss.login()
  File "/home/wah/Workspaces/Firstrade-Profilio-Analysis/.venv/lib/python3.13/site-packages/firstrade/account.py", line 133, in login
    need_code = self._handle_mfa()
  File "/home/wah/Workspaces/Firstrade-Profilio-Analysis/.venv/lib/python3.13/site-packages/firstrade/account.py", line 257, in _handle_mfa
    mfa_otp = pyotp.TOTP(self.mfa_secret).now()
  File "/home/wah/Workspaces/Firstrade-Profilio-Analysis/.venv/lib/python3.13/site-packages/pyotp/totp.py", line 64, in now
    return self.generate_otp(self.timecode(datetime.datetime.now()))
           ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wah/Workspaces/Firstrade-Profilio-Analysis/.venv/lib/python3.13/site-packages/pyotp/otp.py", line 35, in generate_otp
    hasher = hmac.new(self.byte_secret(), self.int_to_bytestring(input), self.digest)
                      ~~~~~~~~~~~~~~~~^^
  File "/home/wah/Workspaces/Firstrade-Profilio-Analysis/.venv/lib/python3.13/site-packages/pyotp/otp.py", line 52, in byte_secret
    return base64.b32decode(secret, casefold=True)
           ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/base64.py", line 252, in b32decode
    return _b32decode(_b32alphabet, s, casefold, map01)
  File "/usr/lib/python3.13/base64.py", line 234, in _b32decode
    raise binascii.Error('Non-base32 digit found') from None
binascii.Error: Non-base32 digit found

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions