类似于用Python编写的Google身份验证器。
项目描述
pyauthenticator
类似于用Python编写的Google身份验证器。随着越来越多的服务需要两步验证,而不支持应用特定密码或其他形式的基于令牌的身份验证,这个Python包允许在命令行或Python中生成两步验证代码。
对于用户
安装
使用conda安装pyauthenticator
>>> conda install -c conda-forge pyauthenticator
或者,也可以通过pip安装pyauthenticator
>>> pip install pyauthenticator
命令行
使用pyauthenticator --help/-h
选项获取如何使用pyauthenticator
的帮助信息
>>> 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.
将google
作为新服务添加到桌面上的Screenshot 2023-07-02 at 12.45.09.png
二维码后
>>> 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>
之后,可以使用以下方法为服务google
生成新的认证代码:
>>> pyauthenticator google
087078
除了Google之外,pyauthenticator
还可以适用于任何实现两步验证的服务。
如果您误输了服务名称,那么pyauthenticator
将建议替代选项
>>> 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>
支持
对于任何支持请求,请随时在Github上打开问题。
对于开发者
Python接口
命令行上可用的相同功能也通过Python接口提供
from pyauthenticator import get_two_factor_code
get_two_factor_code(service)
因此,pyauthenticator
可以集成到需要访问受两步验证保护资源的现有Python包中。
配置
配置存储在~/.pyauthenticator
中,它以JSON格式编写。对于给定的服务如github
,配置文件包含
{"google": "otpauth://totp/Google:<username>?secret=<secret>&issuer=Google"}
Google用户名<username>
和相应的密钥<secret>
包含在二维码中。
许可
pyauthenticator
软件包根据BSD-3-Clause许可许可。
项目细节
下载文件
下载适合您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。
源代码分发
pyauthenticator-0.2.0.tar.gz (23.3 kB 查看哈希值)
构建分发
pyauthenticator-0.2.0-py3-none-any.whl (12.4 kB 查看哈希值)
关闭
pyauthenticator-0.2.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 1efa76acbbc124950501d2e812fb9f84d28be9c4ec1cb0a4f323a0006b7464f5 |
|
MD5 | 2e9821d5052fe4188d32e5be66fce707 |
|
BLAKE2b-256 | d5d02b9adc55aff8b76980ab096dc573d56b26b2315d1dc8923dd5016212b2f8 |
关闭
pyauthenticator-0.2.0-py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | cb68985f0c55ae42d1572735953296203123143c983d83bead566623a68d72d2 |
|
MD5 | c8c2d0255087cd9e8fd1a93e2f73fd5e |
|
BLAKE2b-256 | ba31caf0330720196d6d761d67c8e872a886332ce98643b9a5f87ed6d8dd28ba |