{"id":27427,"library":"stups-tokens","title":"STUPS Tokens","description":"Python library to manage OAuth access tokens, primarily used within the STUPS infrastructure by Zalando. It retrieves tokens from a token service via OAuth2 client credentials flow. Latest version 1.1.19; no longer actively maintained.","status":"maintenance","version":"1.1.19","language":"python","source_language":"en","source_url":"https://github.com/zalando-stups/python-tokens","tags":["oauth2","tokens","stups","zalando","authentication"],"install":[{"cmd":"pip install stups-tokens","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"HTTP client for token requests","package":"requests","optional":false}],"imports":[{"note":"Module name is stups_tokens, not stups.tokens","wrong":"from stups import tokens","symbol":"Tokens","correct":"from stups_tokens import Tokens"}],"quickstart":{"code":"import os\nfrom stups_tokens import Tokens\n\ntokens = Tokens(\n    url=os.environ.get('OAUTH2_ACCESS_TOKEN_URL', ''),\n    client_id=os.environ.get('CLIENT_ID', ''),\n    client_secret=os.environ.get('CLIENT_SECRET', ''),\n    realm='services',\n    scope='uid'\n)\ntoken = tokens.get('myservice')\nprint(token)","lang":"python","description":"Retrieve an OAuth2 token for a service using environment variables for configuration."},"warnings":[{"fix":"Set OAUTH2_ACCESS_TOKEN_URL before instantiation.","message":"The library expects the token service URL via OAUTH2_ACCESS_TOKEN_URL or OAUTH_ACCESS_TOKEN_URL (fallback). If neither is set, it will silently fail with a confusing error.","severity":"gotcha","affected_versions":"all"},{"fix":"Always check if token is not None before use.","message":"Token objects are strings, but get() may return None if token retrieval fails. Not checking for None leads to AttributeError.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade to >=1.0.14 or conditionally pass the flag.","message":"In version 1.0.14, the 'ignore_expiration' flag was added. Code written before that version will not have this parameter, causing TypeError if passed.","severity":"breaking","affected_versions":"<1.0.14"},{"fix":"Migrate to a maintained OAuth2 library.","message":"The library is no longer actively maintained. For new projects, consider alternatives like requests-oauthlib or authlib.","severity":"deprecated","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Export OAUTH2_ACCESS_TOKEN_URL before running your script.","cause":"Environment variable not set or misspelled.","error":"KeyError: 'OAUTH2_ACCESS_TOKEN_URL'"},{"fix":"Upgrade stups-tokens to 1.0.14 or later: pip install --upgrade stups-tokens","cause":"Using ignore_expiration parameter with an older version of the library.","error":"TypeError: __init__() got an unexpected keyword argument 'ignore_expiration'"},{"fix":"Check if token is not None before calling .decode() or using it as a string.","cause":"tokens.get() returned None due to token retrieval failure, and code assumed a string.","error":"AttributeError: 'NoneType' object has no attribute 'decode'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}