Registry / auth-security / yubico-client

yubico-client

JSON →
library1.13.0pypypi✓ verified 72d ago

A Python library for verifying YubiKey One Time Passwords (OTPs) via the Yubico validation API. Version 1.13.0 is stable with infrequent releases.

pip install yubico-client
INSTALL
IMPORT
SIG · YUBICO-CLIENT
Y
yubico-client
auth-securitypythonv1.13.0
Install
2.1s avg
Import
623ms
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.13.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.658s · 21.1MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.1s · import 0.588s · 22MB
19MB installed
● package 19MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Yubico
from yubico_client import Yubico
Standard import path since 1.0.

Verify a YubiKey OTP using the Yubico validation API.

import os from yubico_client import Yubico client_id = os.environ.get('YUBICO_CLIENT_ID', '') secret_key = os.environ.get('YUBICO_SECRET_KEY', '') yubi = Yubico(client_id, secret_key) otp = 'ccccccbcvghfvbjfbbgvhu' # example OTP if yubi.verify(otp): print('OTP is valid') else: print('OTP verification failed')
yubico-client --version
Debug
Known issues
breakingIn version 1.0, the import changed: 'import yubico' no longer works; use 'from yubico_client import Yubico'.
fix
Update imports to 'from yubico_client import Yubico'.
affects: >=1.0
gotchaThe library uses the Yubico validation API v2. You must have a client ID and secret key from Yubico. Without them, verify() will raise an exception.
fix
Set environment variables YUBICO_CLIENT_ID and YUBICO_SECRET_KEY.
affects: all
gotchaverify() returns True/False, not a Yubico response object. For detailed failure reasons, catch exceptions from yubico_client.errors.
fix
Use try/except around verify() to get exceptions like YubicoVerificationError.
affects: all
Errors
Common errors & fixes
ImportError: No module named yubico_client
Installed old 'yubico' package or forgot to install yubico-client.
fix
Run 'pip install yubico-client' and use 'from yubico_client import Yubico'.
AttributeError: module 'yubico_client' has no attribute 'Yubico'
Used old import 'import yubico' instead of 'from yubico_client import Yubico'.
fix
Change import to 'from yubico_client import Yubico'.
yubico_client.errors.YubicoVerificationError: No such client
Invalid client ID or secret key, or missing environment variables.
fix
Check YUBICO_CLIENT_ID and YUBICO_SECRET_KEY values. Generate credentials at https://upgrade.yubico.com/getapikey/.
yubico_client.errors.YubicoVerificationError: Bad OTP
OTP string is malformed or not a valid YubiKey OTP.
fix
Ensure OTP is a 44-character string from a YubiKey. Example: 'ccccccbcvghfvbjfbbgvhu'.
Upgrade
Version history
1.13.0latest on PyPI · released May 21, 2020
Audit
Dependencies

No dependency data recorded yet.

Agent activity
48 hits · last 30 days
node
44
Meta
1
Resources
yubico-client — pip install yubico-client · libregistry