{"id":21388372,"url":"https://github.com/robinvandernoord/lib2fas-python","last_synced_at":"2025-07-13T15:32:29.893Z","repository":{"id":219718288,"uuid":"749759990","full_name":"robinvandernoord/lib2fas-python","owner":"robinvandernoord","description":"Unofficial implementation of 2fas for Python (as a library)","archived":false,"fork":false,"pushed_at":"2024-04-10T12:47:41.000Z","size":69,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-09T05:13:07.602Z","etag":null,"topics":["2fas","python"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/lib2fas/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robinvandernoord.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-01-29T10:43:56.000Z","updated_at":"2024-08-28T22:40:22.000Z","dependencies_parsed_at":"2024-04-10T13:57:54.355Z","dependency_job_id":null,"html_url":"https://github.com/robinvandernoord/lib2fas-python","commit_stats":null,"previous_names":["robinvandernoord/lib2fas-python"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robinvandernoord%2Flib2fas-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robinvandernoord%2Flib2fas-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robinvandernoord%2Flib2fas-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robinvandernoord%2Flib2fas-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robinvandernoord","download_url":"https://codeload.github.com/robinvandernoord/lib2fas-python/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225893661,"owners_count":17540919,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["2fas","python"],"created_at":"2024-11-22T12:16:55.938Z","updated_at":"2024-11-22T12:16:58.223Z","avatar_url":"https://github.com/robinvandernoord.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lib2fas Python\n\nUnofficial implementation of 2fas for Python (as a library).\nThis library serves as the backend for\nthe [robinvandernoord/2fas-python](https://github.com/robinvandernoord/2fas-python) CLI, a command-line tool that\nprovides an easy interface to interact with the 2fas TOTP.\n\n## Installation\n\nTo install this project, use pip:\n\n```bash\npip install lib2fas\n# or to also install the cli tool:\npip install 2fas\n```\n\n## Usage\n\nAfter installing the package, you can import it in your Python scripts as follows:\n\n```python\nimport lib2fas\n\nservices = lib2fas.load_services(\"/path/to/file.2fas\", passphrase=\"optional\")  # -\u003e TwoFactorStorage\n\nservices.generate()  # generate all TOTP keys\n\ngmail = services[\"gmail\"]  # exact match (case-insensitive), returns a list of 'TwoFactorAuthDetails' instances.\n\ngithub = services.find(\"githbu\")  # fuzzy match should find GitHub, returns a new TwoFactorStorage.\n\nfor label, services in github.items():\n    # one label can have multiple services!\n    for service in services:  # 'service' is a TwoFactorAuthDetails instance\n        # Print label, service name, and TOTP code\n        print(\"Label:\", label)\n        print(\"Service Name:\", service.name)\n        print(\"TOTP Code:\", service.generate())  # or .generate_int() to get the code as a number.\n```\n\nThe `passphrase` option of `load_services` is optional.\nIf you don't provide a password, but your file is encrypted, you will be prompted for the passphrase.\nIf possible, this will be safely stored in the keychain manager of your OS* until the next reboot.\n\n* Note: only the \"Secret Storage\" keychain backend on Ubuntu Linux has been tested.\n\n## License\n\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobinvandernoord%2Flib2fas-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobinvandernoord%2Flib2fas-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobinvandernoord%2Flib2fas-python/lists"}