stups-zign

raw JSON →
1.2.2 verified Fri May 01 auth: no python maintenance

OAuth2 token management CLI for obtaining and storing OAuth2 access tokens from OpenID Connect providers. Version 1.2.2 supports Python >=3.10. Developed by Zalando, no longer actively maintained.

pip install stups-zign
error ModuleNotFoundError: No module named 'zign'
cause The library is installed as 'stups-zign' but imported as 'zign'.
fix
Use 'import zign' after installing 'pip install stups-zign'.
error AttributeError: module 'zign' has no attribute 'ZignTokenManager'
cause ZignTokenManager is not imported correctly; it's in zign.api.
fix
Use 'from zign.api import ZignTokenManager'.
error FileNotFoundError: [Errno 2] No such file or directory: '/home/user/.zign/tokens.json'
cause The tokens file does not exist until a token is first saved.
fix
Call get_token() to create the file automatically, or create an empty JSON file manually.
deprecated stups-zign is in maintenance mode. The Zalando STUPS ecosystem is being phased out. Consider migrating to keyring-based token storage or using OAuth2 libraries directly.
fix Migrate to alternative token management solutions.
gotcha Token storage path defaults to ~/.zign/tokens.json. Ensure read/write permissions in that directory.
fix Set the ZIGN_TOKEN_DIR environment variable to a custom path if needed.
gotcha The get_token method raises a KeyError if the required fields are missing in the response. Always check for access_token in the returned dict.
fix Use .get('access_token') and handle missing token gracefully.

Initialize token manager and obtain an OAuth2 token using environment variables.

from zign.api import ZignTokenManager
import os

# Use environment variables for credentials (common pattern)
client_id = os.environ.get('ZIGN_CLIENT_ID', '')
client_secret = os.environ.get('ZIGN_CLIENT_SECRET', '')
url = os.environ.get('ZIGN_TOKEN_URL', 'https://example.com/oauth2/token')

manager = ZignTokenManager()
token = manager.get_token(url=url, client_id=client_id, client_secret=client_secret)
print(token.get('access_token', 'No token retrieved'))