Problem description
The X-Amz-Credential field in your request is malformed. This error occurs when you use the S3-compatible API with Signature Version 4 (V4) authentication.
Causes
The X-Amz-Credential field must follow this exact format:
| Field | Format | Example |
|---|---|---|
X-Amz-Credential | <AccessKey-ID>/<date>/<region>/<service>/aws4_request | LTAI****************/20221220/us-east-1/s3/aws4_request |
Each component is required:
| Component | Description | Example |
|---|---|---|
<AccessKey-ID> | Your Alibaba Cloud AccessKey ID | LTAI**************** |
<date> | Signing date in YYYYMMDD format | 20221220 |
<region> | The target region | us-east-1 |
<service> | The service name | s3 |
aws4_request | A fixed literal string | aws4_request |
Examples
The following request fails because the <date> component (YYYYMMDD) is missing from X-Amz-Credential:
GET /test.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=LTAI****************/us-east-1/s3/aws4_request&X-Amz-Date=20221220T084818Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=ab2**** HTTP/1.0
Date: Tue, 20 Dec 2022 08:48:18 GMT
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
x-oss-s3-compat: trueThe value LTAI****************/us-east-1/s3/aws4_request is missing 20221220 between the AccessKey ID and the region.
Solutions
Add the missing date component. The corrected request:
GET /test.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=LTAI****************/20221220/us-east-1/s3/aws4_request&X-Amz-Date=20221220T084818Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=ab2s**** HTTP/1.0
Date: Tue, 20 Dec 2022 08:48:18 GMT
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
x-oss-s3-compat: trueTo avoid manually constructing the credential string, use an Amazon S3 SDK, which builds the X-Amz-Credential field automatically. For setup instructions, see Use Amazon S3 SDKs to access OSS.
该文章对您有帮助吗?