diff --git a/include/aws/s3/s3.h b/include/aws/s3/s3.h index 49b9a542..144969d0 100644 --- a/include/aws/s3/s3.h +++ b/include/aws/s3/s3.h @@ -49,6 +49,7 @@ enum aws_s3_errors { AWS_ERROR_S3_RECV_FILE_ALREADY_EXISTS, AWS_ERROR_S3_RECV_FILE_NOT_FOUND, AWS_ERROR_S3_REQUEST_TIMEOUT, + AWS_ERROR_S3_TOKEN_EXPIRED, AWS_ERROR_S3_END_RANGE = AWS_ERROR_ENUM_END_RANGE(AWS_C_S3_PACKAGE_ID) }; diff --git a/source/s3.c b/source/s3.c index a5a0d739..08aa1199 100644 --- a/source/s3.c +++ b/source/s3.c @@ -52,6 +52,7 @@ static struct aws_error_info s_errors[] = { AWS_DEFINE_ERROR_INFO_S3(AWS_ERROR_S3_RECV_FILE_ALREADY_EXISTS, "File already exists, cannot create as new."), AWS_DEFINE_ERROR_INFO_S3(AWS_ERROR_S3_RECV_FILE_NOT_FOUND, "The receive file doesn't exist, cannot create as configuration required."), AWS_DEFINE_ERROR_INFO_S3(AWS_ERROR_S3_REQUEST_TIMEOUT, "RequestTimeout error received from S3."), + AWS_DEFINE_ERROR_INFO_S3(AWS_ERROR_S3_TOKEN_EXPIRED, "Token expired - needs a refresh."), }; /* clang-format on */ diff --git a/source/s3_util.c b/source/s3_util.c index d2dc46d7..1c6aecb8 100644 --- a/source/s3_util.c +++ b/source/s3_util.c @@ -682,6 +682,11 @@ int aws_s3_crt_error_code_from_recoverable_server_error_code_string(struct aws_b return AWS_ERROR_S3_REQUEST_TIMEOUT; } + if (aws_byte_cursor_eq_c_str_ignore_case(&error_code_string, "ExpiredToken") || + aws_byte_cursor_eq_c_str_ignore_case(&error_code_string, "TokenRefreshRequired")) { + return AWS_ERROR_S3_TOKEN_EXPIRED; + } + return AWS_ERROR_UNKNOWN; }