{"id":23307,"library":"aws-bedrock-token-generator","title":"AWS Bedrock Token Generator","description":"A lightweight library for generating short-term bearer tokens for AWS Bedrock API authentication. Version 1.1.0, supports Python >=3.7. Released by AWS. Used to obtain tokens for invoking Bedrock without managing long-lived credentials.","status":"active","version":"1.1.0","language":"python","source_language":"en","source_url":"https://github.com/aws/aws-bedrock-token-generator-python","tags":["aws","bedrock","token","auth","bearer"],"install":[{"cmd":"pip install aws-bedrock-token-generator","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"AWS SDK for Python, required for signing requests","package":"boto3","optional":false},{"reason":"HTTP library for token retrieval","package":"requests","optional":false}],"imports":[{"note":"Module name uses underscores, not hyphens","wrong":"from bedrock_token_generator import get_bearer_token","symbol":"get_bearer_token","correct":"from aws_bedrock_token_generator import get_bearer_token"},{"note":"Class is directly importable from package","wrong":"from aws_bedrock_token_generator.generator import BedrockTokenGenerator","symbol":"BedrockTokenGenerator","correct":"from aws_bedrock_token_generator import BedrockTokenGenerator"}],"quickstart":{"code":"from aws_bedrock_token_generator import get_bearer_token\nimport os\n\n# AWS credentials must be configured (via env vars or boto3 session)\ntoken = get_bearer_token()\n# token is a dict: {'access_token': '...', 'expires_in': 3600}\nprint(token['access_token'])","lang":"python","description":"Generate a bearer token using default AWS credentials (from environment or ~/.aws/credentials)."},"warnings":[{"fix":"Use BedrockTokenGenerator class or implement your own caching with token expiry check.","message":"The token expires quickly (default 1 hour). Do not cache tokens without respecting the expiry. Re-generate for each session or use the BedrockTokenGenerator class with caching built-in.","severity":"gotcha","affected_versions":"<=1.1.0"},{"fix":"Use `from aws_bedrock_token_generator import BedrockTokenGenerator` and instantiate `generator = BedrockTokenGenerator()` then call `generator.get_token()`.","message":"The low-level `get_bearer_token` function is deprecated in favor of the `BedrockTokenGenerator` class which provides better caching and refresh logic.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Ensure AWS credentials are set via environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) or a default profile.","message":"The library requires boto3 and AWS credentials. If credentials are missing, it raises a `CredentialsError` (from boto3).","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"pip install aws-bedrock-token-generator; then use `import aws_bedrock_token_generator` (underscores).","cause":"Installed the package with hyphens but importing with hyphens is invalid.","error":"ImportError: No module named 'aws_bedrock_token_generator'"},{"fix":"Set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables or configure ~/.aws/credentials.","cause":"AWS credentials not configured.","error":"botocore.exceptions.NoCredentialsError: Unable to locate credentials"},{"fix":"Upgrade to >=1.0.0 or import `from aws_bedrock_token_generator.core import get_bearer_token`.","cause":"Using an older version where the function was named differently or not imported at package level.","error":"AttributeError: module 'aws_bedrock_token_generator' has no attribute 'get_bearer_token'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}