Skip to main content

Blizzard Authenticator and OTP library in Python

Project description

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())

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

bna-5.0.2.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

bna-5.0.2-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file bna-5.0.2.tar.gz.

File metadata

  • Download URL: bna-5.0.2.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.9.2 Linux/5.11.1-arch1-1

File hashes

Hashes for bna-5.0.2.tar.gz
Algorithm Hash digest
SHA256 66090640ea9eebbf98718a8b3fe5aa531caaeb0411a8cf49898ede06e459c0ee
MD5 884a44f07069fc1f5713ef6c617f6056
BLAKE2b-256 4b7fd7d5847ac9df15aef44f8bc94549408476d02e870544fcf032cb0e43aecd

See more details on using hashes here.

File details

Details for the file bna-5.0.2-py3-none-any.whl.

File metadata

  • Download URL: bna-5.0.2-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.9.2 Linux/5.11.1-arch1-1

File hashes

Hashes for bna-5.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ded5ee565720d8b9c0b7aa5051ca49ab71b8c0a42f1194728d43e046618bab31
MD5 913235c9a7b9b90a954272386265e1a2
BLAKE2b-256 bc8fbac40126fd66ed270330fd41a98c24f4253a8db97171637a9c6077dd586f

See more details on using hashes here.

Supported by

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