Skip to main content

python-bna

Requirements

  • Python 3.6+

Command-line usage

bna is a command line interface to the python-bna library. It can store and manage multiple authenticators, as well as create new ones.

Remember: Using an authenticator on the same device as the one you log in with is less secure than keeping the devices separate. Use this at your own risk.

Configuration is stored in ~/.config/bna/bna.conf. You can pass a different config path with bna --config=~/.bna.conf for example.

Creating a new authenticator

$ bna new

If you do not already have an authenticator, it will be set as default. You can pass --set-default otherwise.

Getting an authentication token

$ bna
01234567
$ bna EU-1234-1234-1234
76543210

Getting an authenticator's restore code

$ bna show-restore-code
Z45Q9CVXRR
$ bna restore EU-1234-1234-1234 ABCDE98765
Restored EU-1234-1234-1234

Getting an OTPAuth URL

To display the OTPAuth URL (used for setup QR Codes):

$ bna show-url
otpauth://totp/Blizzard:EU123412341234:?secret=ASFAS75ASDF75889G9AD7S69AS7697AS&issuer=Blizzard&digits=8

Now paste this to your OTP app, or convert to QRCode and scan, or manually enter the secret.

This is compatible with standard TOTP clients and password managers such as:

Getting a QR code

To encode to a QRCode on your local system install 'qrencode'

For a PNG file saved to disk :

$ bna show-url | qrencode -o ~/BNA-qrcode.png
# Scan QRCode
$ rm ~/BNA-qrcode.png

Or to attempt ot display QRCode in terminal as text output :

$ bna --otpauth-url | qrencode -t ANSI

Python library usage

Requesting a new authenticator

import bna
try:
    # region is EU or US
    # note that EU authenticators are valid in the US, and vice versa
    serial, secret = bna.request_new_serial("US")
except bna.HTTPError as e:
    print("Could not connect:", e)

Getting a token

    # Get and print a token using PyOTP
    from pyotp import TOTP
    totp = TOTP(secret, digits=8)
    print(totp.now())

Release files for bna 5.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bna 5.1.0
File Size Uploaded
bna-5.1.0.tar.gz 9.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bna 5.1.0
File Interpreter ABI Platform
bna-5.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.9 kB

Release files / bna-5.1.0.tar.gz

Download URL bna-5.1.0.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f6c53527bc8fe35853f4962b67c8056d98b5adb6ba6cfd713506bc175bbb67a7
BLAKE2b-256 checksum
How to use checksums
9cad0fc9852ebd44187830c4c1998e6d1aa697d003b59fae6890eabb1456b374
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.0a2 CPython/3.10.2 Linux/5.16.4-arch1-1

Release files / bna-5.1.0-py3-none-any.whl

Download URL bna-5.1.0-py3-none-any.whl
Size 10.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a0530ec32406b24404ae98ae422fc15dc3c46ce441912a6c12f3e4bd0e942323
BLAKE2b-256 checksum
How to use checksums
760be823367598f27bc27833952a1509854d09e77bbcb1031f1106b26eee40d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.0a2 CPython/3.10.2 Linux/5.16.4-arch1-1

Release history Release notifications | RSS feed

This release

5.1.0 This release

2 release files

5.0.2

2 release files

5.0.1

2 release files

5.0.0

2 release files

4.1.0

1 release file

4.0.1

1 release file

4.0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page