`An error occurred (ExpiredToken) when calling the ... operation: The security token included in the request is expired` midway through a long job.
AdvancedTroubleshootingboto3, HTTP & API errors
Answer
Likely causes → The job built a Session from static STS credentials (manual assume_role) that expired after 1 hour; or SSO session expired.
Diagnose → Check how the Session is created and the job duration vs DurationSeconds.
Fix → Use a profile with role_arn + source_profile/credential_source so botocore refreshes automatically, or use botocore.credentials.RefreshableCredentials with a refresh callback. Increase role MaxSessionDuration if needed.
Prevent → Let botocore manage assume-role; avoid passing raw keys into Session().
More on boto3, HTTP & API errors
`botocore.exceptions.NoCredentialsError: Unable to locate credentials`Beginner`botocore.exceptions.NoRegionError: You must specify a region.` even though `AWS_REGION` is set.Intermediate`botocore.exceptions.ClientError: An error occurred (UnauthorizedOperation) when calling the DescribeInstances operation: You are not authorized to perform this operation.`Beginner`An error occurred (RequestLimitExceeded) when calling the DescribeInstances operation (reached max retries: 4): Request limit exceeded.`Intermediate`An error occurred (InvalidClientTokenId) when calling the GetCallerIdentity operation: The security token included in the request is invalid.`Beginner`An error occurred (SignatureDoesNotMatch)` or `RequestTimeTooSkewed` from AWS.Intermediate