Similar to the Google authenticator just written in python.
Project description
pyauthenticator
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.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pyauthenticator-0.2.0.tar.gz
.
File metadata
- Download URL: pyauthenticator-0.2.0.tar.gz
- Upload date:
- Size: 23.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1efa76acbbc124950501d2e812fb9f84d28be9c4ec1cb0a4f323a0006b7464f5 |
|
MD5 | 2e9821d5052fe4188d32e5be66fce707 |
|
BLAKE2b-256 | d5d02b9adc55aff8b76980ab096dc573d56b26b2315d1dc8923dd5016212b2f8 |
File details
Details for the file pyauthenticator-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: pyauthenticator-0.2.0-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb68985f0c55ae42d1572735953296203123143c983d83bead566623a68d72d2 |
|
MD5 | c8c2d0255087cd9e8fd1a93e2f73fd5e |
|
BLAKE2b-256 | ba31caf0330720196d6d761d67c8e872a886332ce98643b9a5f87ed6d8dd28ba |