Skip to content

TWO_FACTOR_AUTHENTICATION_REQUIRED #28

Closed

Description

@littleyoda

Describe the bug

I am receiving an error regarding two-factor authentication.
Is there already a way to work around this error, or are there plans to implement two-factor authentication

Steps to reproduce the issue

``
from python_picnic_api2 import PicnicAPI
p = PicnicAPI("XXXX","YYYYYYY",'de');
p.get_deliveries()

{'error': {'code': 'TWO_FACTOR_AUTHENTICATION_REQUIRED', 'message': 'User must verify their second factor', 'details': {}}}
``

What did you expect to happen instead?

x

Python Version

3.13

Activity

  1. added
    bug
    on Mar 1, 2026
  2. littleyoda commented on Mar 1, 2026

    @littleyoda
    Author

    The NPM-Implementition for picnic already contains function for 2FA:

    https://github.com/MRVDH/picnic-api/blob/7dfbab91721b07651be8f4efa9e0c699f131ee58/src/index.ts#L105

  3. littleyoda commented on Mar 1, 2026

    @littleyoda
    Author

    Please find attached a first implementation for two-factor authentication.
    Unfortunately, currently only available as a diff in a text file.

    diff.txt

    from python_picnic_api2 import PicnicAPI
    p = PicnicAPI(user,pwd,'de');
    print(F"2FA required: {p.is_2FA_Required()}")
    
    
    print(p.generate_2fa_code())
    
    if p.verify_2fa_code("294109"):
        print("Code ok")
    else:
        print("Code wrong")
    
    print(len(p.get_deliveries()))
    
    print("Extracting Token for next login")
    auth = p.session.auth_token
    print(auth)
    
    p = PicnicAPI(user,pwd,'de',auth_token = auth);
    
    
  4. codesalatdev commented on Mar 1, 2026

    @codesalatdev
    Owner

    Why did you close this issue? The integration tests started to fail today, so IMO this is still relevant?

  5. littleyoda commented on Mar 1, 2026

    @littleyoda
    Author

    Closing it was a mistake. I havn't the rights to reopen the issue.

  6. codesalatdev commented on Mar 1, 2026

    @codesalatdev
    Owner

    Ah I see, I will reopen and implement the function, thank you for the diff! :)

  7. codesalatdev commented on Mar 2, 2026

    @codesalatdev
    Owner

    Thanks for the report! The 2FA flow is added in version v1.3.3 https://pypi.org/project/python-picnic-api2/1.3.3/

  8. littleyoda commented on Mar 2, 2026

    @littleyoda
    Author

    Would you mind updating the readme file with a short information on how to use 2FA?

  9. codesalatdev commented on Mar 2, 2026

    @codesalatdev
    Owner

    Would you mind updating the readme file with a short information on how to use 2FA?

    Updated: https://github.com/codesalatdev/python-picnic-api?tab=readme-ov-file#two-factor-authentication-2fa :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions