Registry / auth-security / scitokens

scitokens

JSON →
library1.9.7pypypi✓ verified 84d ago

Reference implementation of the SciToken authentication and authorization library, providing token creation, validation, and enforcement for distributed scientific computing. Current version 1.9.7, requires Python >=3.5. Releases are irregular, driven by community needs.

pip install scitokens
INSTALL
IMPORT
SIG · SCITOKENS
S
scitokens
auth-securitypythonv1.9.7
Install
3.0s avg
Import
234ms
Disk
36MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.9.7 · 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.248s · 38.1MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.0s · import 0.220s · 38MB
36MB installed
● package 36MB
Code
Verified usage

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

SciToken
from scitokens import SciToken
Enforcer
from scitokens import Enforcer

Create and serialize an unprotected SciToken using an issuer and key ID.

import scitokens import os token = scitokens.SciToken( issuer=os.environ.get('SCITOKENS_ISSUER', 'https://example.com/'), key_id='rsa_key', ) token.update_claims({'sub': 'user123', 'scope': 'read:/data'}) serialized = token.serialize(serialization_type='unprotected') print(serialized)
scitokens-admin --version
Debug
Known issues
gotchaSerialization type 'unprotected' produces a token without signature; use with caution. For production, use 'jws' or a proper key.
fix
Provide a valid private key and use serialize() without serialization_type for signed tokens.
affects: all
gotchaThe library may change the default algorithm between versions; always specify algorithm explicitly when creating tokens to avoid surprises.
fix
Use SciToken(algorithm='RS256', ...) or the appropriate algorithm.
affects: all
Errors
Common errors & fixes
ImportError: cannot import name 'SciToken' from 'scitokens'
Older versions of scitokens placed SciToken under scitokens.scitokens; newer versions export directly from scitokens.
fix
Use 'from scitokens import SciToken' with version >=1.0.0.
scitokens.exceptions.TokenValidationError: Token has expired
The token's expiration claim ('exp') is in the past or not properly set.
fix
Ensure the token's 'exp' claim is set to a future time. For example: token.update_claims({'exp': int(time.time()) + 3600}).
Upgrade
Version history
1.9.7latest on PyPI · released Mar 13, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
26 hits · last 30 days
node
24
OpenAI (training)
1
Resources
scitokens — pip install scitokens · libregistry