{"id":22342,"library":"scitokens","title":"SciTokens","description":"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.","status":"active","version":"1.9.7","language":"python","source_language":"en","source_url":"https://github.com/scitokens/scitokens","tags":["authentication","authorization","scientific computing","tokens"],"install":[{"cmd":"pip install scitokens","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"note":"","wrong":"","symbol":"SciToken","correct":"from scitokens import SciToken"},{"note":"","wrong":"","symbol":"Enforcer","correct":"from scitokens import Enforcer"}],"quickstart":{"code":"import scitokens\nimport os\n\ntoken = scitokens.SciToken(\n    issuer=os.environ.get('SCITOKENS_ISSUER', 'https://example.com/'),\n    key_id='rsa_key',\n)\ntoken.update_claims({'sub': 'user123', 'scope': 'read:/data'})\nserialized = token.serialize(serialization_type='unprotected')\nprint(serialized)","lang":"python","description":"Create and serialize an unprotected SciToken using an issuer and key ID."},"warnings":[{"fix":"Provide a valid private key and use serialize() without serialization_type for signed tokens.","message":"Serialization type 'unprotected' produces a token without signature; use with caution. For production, use 'jws' or a proper key.","severity":"gotcha","affected_versions":"all"},{"fix":"Use SciToken(algorithm='RS256', ...) or the appropriate algorithm.","message":"The library may change the default algorithm between versions; always specify algorithm explicitly when creating tokens to avoid surprises.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use 'from scitokens import SciToken' with version >=1.0.0.","cause":"Older versions of scitokens placed SciToken under scitokens.scitokens; newer versions export directly from scitokens.","error":"ImportError: cannot import name 'SciToken' from 'scitokens'"},{"fix":"Ensure the token's 'exp' claim is set to a future time. For example: token.update_claims({'exp': int(time.time()) + 3600}).","cause":"The token's expiration claim ('exp') is in the past or not properly set.","error":"scitokens.exceptions.TokenValidationError: Token has expired"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}