When running this:
session = boto3.session.Session()
client = session.client(service_name="secretsmanager", region_name='region')
secret_response = client.get_secret_value(SecretId='secret_name')
print(secret_response)
This is the error that I get: botocore.exceptions.ClientError: An error occurred (UnrecognizedClientException) when calling the GetSecretValue operation: The security token included in the request is invalid.
But when I run the exact same code but specify my profile like this:
session = boto3.session.Session(profile_name='default')
it works.
boto3 version: 1.27.6