Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#173] Boto3 client kwargs passthrough #176

Merged
merged 1 commit into from
Nov 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pycognito/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ def __init__(
secret_key=None,
session=None,
botocore_config=None,
boto3_client_kwargs=None,
):
"""
:param user_pool_id: Cognito User Pool ID
Expand All @@ -168,6 +169,7 @@ def __init__(
:param secret_key: AWS IAM secret key
:param session: Boto3 client session
:param botocore_config: Botocore Config object for the client
:param boto3_client_kwargs: Keyword args to pass to Boto3 for client creation
"""

self.user_pool_id = user_pool_id
Expand All @@ -188,7 +190,8 @@ def __init__(
self.pool_jwk = None
self.mfa_tokens = None

boto3_client_kwargs = {}
if not boto3_client_kwargs:
boto3_client_kwargs = {}
if access_key and secret_key:
boto3_client_kwargs["aws_access_key_id"] = access_key
boto3_client_kwargs["aws_secret_access_key"] = secret_key
Expand Down
3 changes: 3 additions & 0 deletions pycognito/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def __init__(
http_header: str = "Authorization",
http_header_prefix: str = "Bearer ",
auth_token_type: TokenType = TokenType.ACCESS_TOKEN,
boto3_client_kwargs=None,
):
"""

Expand All @@ -57,6 +58,7 @@ def __init__(
:param http_header: The HTTP Header to populate. Defaults to "Authorization" (Basic Authentication)
:param http_header_prefix: Prefix a value before the token. Defaults to "Bearer ". (Note the space)
:param auth_token_type: Whether to populate the header with ID or ACCESS_TOKEN. Defaults to "ACCESS_TOKEN"
:param boto3_client_kwargs: Keyword args to pass to Boto3 for client creation
"""

if cognito:
Expand All @@ -67,6 +69,7 @@ def __init__(
client_id=client_id,
user_pool_region=user_pool_region,
username=username,
boto3_client_kwargs=boto3_client_kwargs,
)

self.username = username
Expand Down