Registry / aws / aws-bedrock-token-generator

aws-bedrock-token-generator

JSON →
library1.1.0pypypi✓ verified 80d ago

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.

pip install aws-bedrock-token-generator
INSTALL
IMPORT
SIG · AWS-BEDROCK-TOKEN-
A
aws-bedrock-token-generator
awspythonv1.1.0
Install
3.1s avg
Import
Disk
47MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.0 · 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.000s · 48.7MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.1s · import 0.000s · 49MB
47MB installed
● package 47MB
Code
Verified usage

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

BedrockTokenGenerator
from aws_bedrock_token_generator import BedrockTokenGenerator
from aws_bedrock_token_generator import get_bearer_token
provide_token
from aws_bedrock_token_generator import provide_token
from aws_bedrock_token_generator import get_bearer_token
token_generator
from aws_bedrock_token_generator import token_generator
from aws_bedrock_token_generator import get_bearer_token

Generate a bearer token using default AWS credentials (from environment or ~/.aws/credentials).

from aws_bedrock_token_generator import get_bearer_token import os # AWS credentials must be configured (via env vars or boto3 session) token = get_bearer_token() # token is a dict: {'access_token': '...', 'expires_in': 3600} print(token['access_token'])
Debug
Known issues
gotchaThe 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.
fix
Use BedrockTokenGenerator class or implement your own caching with token expiry check.
affects: <=1.1.0
deprecatedThe low-level `get_bearer_token` function is deprecated in favor of the `BedrockTokenGenerator` class which provides better caching and refresh logic.
fix
Use `from aws_bedrock_token_generator import BedrockTokenGenerator` and instantiate `generator = BedrockTokenGenerator()` then call `generator.get_token()`.
affects: >=1.0.0
gotchaThe library requires boto3 and AWS credentials. If credentials are missing, it raises a `CredentialsError` (from boto3).
fix
Ensure AWS credentials are set via environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) or a default profile.
affects: all
Upgrade
Version history
1.1.0latest on PyPI · released Jul 29, 2025
Audit
Dependencies
boto3requiredAWS SDK for Python, required for signing requests
requestsrequiredHTTP library for token retrieval
Agent activity
32 hits · last 30 days
node
30
OpenAI (training)
1
Resources
aws-bedrock-token-generator — pip install aws-bedrock-token-generator · libregistry