Skip to main content

Similar to the Google authenticator just written in python.

Project description

pyauthenticator

Pipeline Coverage Status Code style: black

Similar to the Google authenticator just written in Python. With more and more services requiring two factor authentication without supporting application specific passwords or other forms of token based authenication suitable for automation this python packages allows to generate two factor authentication codes on the commandline or in python.

Preview of pyauthenticator

For Users

Installation

Install pyauthenticator via conda:

>>> conda install -c conda-forge pyauthenticator

Alternatively, pyauthenticator can also be installed via pip:

>>> pip install pyauthenticator

Command Line

Get help how to use pyauthenticator using the --help/-h option:

>>> pyauthenticator --help

usage: pyauthenticator [-h] [-qr] [-a ADD] service

positional arguments:
  service            Service to generate optauth code for. Currently no
                     service is defined in the ~/.pyauthenticator config file.

options:
  -h, --help         show this help message and exit
  -qr, --qrcode      Generate qrcode as <service.png> file.
  -a ADD, --add ADD  Add service by providing the <qrcode.png> file as
                     additional argument.

Add google as new service after saving the qrcode to Screenshot 2023-07-02 at 12.45.09.png to your desktop:

>>> pyauthenticator google --add ~/Desktop/Screenshot\ 2023-07-02\ at\ 12.45.09.png

The service 'google' was added, from file </Users/jan/Desktop/Screenshot 2023-07-02 at 12.45.09.png>

Afterwards, new authentication codes can be generated for the service google using:

>>> pyauthenticator google

087078

Beyond google, pyauthenticator works for any service which implements the two factor authentication.

If you mistype the name of the service, then pyauthenticator suggests alternative options:

>>> pyauthenticator googel

The service "googel" does not exist.

The config file ~/.pyauthenticator contains the following services:
  * google

Choose one of these or add a new service using:
  pyauthenticator --add <qr-code.png> <servicename>

Support

For any support requests feel free to open an issue on Github.

For Developers

Python Interface

The same functionality which is available on the command line is also available via the python interface:

from pyauthenticator import get_two_factor_code
get_two_factor_code(service)

So pyauthenticator can be integrated in existing python packages which need access to resources protected by two factor authentication.

Configuration

The configuration is stored in ~/.pyauthenticator it is written in the JSON format. For a given service like github the config file contains:

{"google": "otpauth://totp/Google:<username>?secret=<secret>&issuer=Google"}

With the Google username <username> and the corresponding secret <secret> being contained in the QR code.

License

The pyauthenticator package is licensed under the BSD-3-Clause license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyauthenticator-0.3.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyauthenticator-0.3.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file pyauthenticator-0.3.0.tar.gz.

File metadata

  • Download URL: pyauthenticator-0.3.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyauthenticator-0.3.0.tar.gz
Algorithm Hash digest
SHA256 8b6fe1f90fbcfa1d2033e25139e5479ab083fbbf1c4337a8ca6dddfc0dfd3e97
MD5 1773dd99fdfcabf3663484755d28e0f5
BLAKE2b-256 d597784149fd181c266ed096c4c7c4a210d540d6952dfe31e7250ad250c7f279

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyauthenticator-0.3.0.tar.gz:

Publisher: deploy.yml on jan-janssen/pyauthenticator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyauthenticator-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pyauthenticator-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7f3a44451f27f1d272b12ddb965b3aa1c95e77cb35c9f1f87acdf097206571a7
MD5 1bf4759e1d54452e7d04c8d05d65b7c2
BLAKE2b-256 0af757432aea69b7eb6c9b869cb8545aa640e416d7f2d0b78e154b641e776142

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyauthenticator-0.3.0-py3-none-any.whl:

Publisher: deploy.yml on jan-janssen/pyauthenticator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page