Skip to content

Instantly share code, notes, and snippets.

@KyMidd
Created July 9, 2025 03:38
Show Gist options
  • Select an option

  • Save KyMidd/c153a02ec89900e532e33fad002afc6f to your computer and use it in GitHub Desktop.

Select an option

Save KyMidd/c153a02ec89900e532e33fad002afc6f to your computer and use it in GitHub Desktop.
def handle_auth_code_callback(body, event, auth_code, aad_object_id):
# ...
encrypted_token_base64 = base64.b64encode(encrypted_token['CiphertextBlob']).decode('utf-8')
# Store the access token in DynamoDB, can be used in future transactions for an hour (default expiration)
dynamodb_client = boto3.client("dynamodb")
dynamodb_client.put_item(
TableName=token_table_arn,
Item={
"aadObjectId": {"S": aad_object_id},
"accessToken": {"S": encrypted_token_base64},
"expiresAt": {"N": str(expires_at)}
}
)
print("🟢 Successfully stored access token in DynamoDB")
# Fetch the conversation body from DynamoDB
response = dynamodb_client.get_item(
TableName=conversation_table_arn,
Key={
"aadObjectId": {"S": aad_object_id}
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment