Skip to main content

Blizzard Authenticator and OTP library in Python

Project description

python-bna

Build Status

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.1.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

bna-5.0.1-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bna-5.0.1.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.9.1 Linux/5.9.14-arch1-1

File hashes

Hashes for bna-5.0.1.tar.gz
Algorithm Hash digest
SHA256 660080f8a722b2513c36dc707c09cd7de934c59c583ab0cf73b51f8ff82ec451
MD5 56ef6db0f7c34eb744cd74408246254a
BLAKE2b-256 46eb895263990524abec342571f548979d7ae31f0853931ab918d592d363edf1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bna-5.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.9.1 Linux/5.9.14-arch1-1

File hashes

Hashes for bna-5.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 63ccfb6f30210261e76e59d70607da3b13b53d4be77026e1b11ab3b663b4ffbd
MD5 72a776f884d5711f4879cfbc84ec5ff9
BLAKE2b-256 b518477fbcd8ebfdab549ef24a6423bdac1ec23d4838ab141bf293d6554a4373

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