0002-00000413

更新时间:
复制 MD 格式

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:

FieldFormatExample
X-Amz-Credential<AccessKey-ID>/<date>/<region>/<service>/aws4_requestLTAI****************/20221220/us-east-1/s3/aws4_request

Each component is required:

ComponentDescriptionExample
<AccessKey-ID>Your Alibaba Cloud AccessKey IDLTAI****************
<date>Signing date in YYYYMMDD format20221220
<region>The target regionus-east-1
<service>The service names3
aws4_requestA fixed literal stringaws4_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: true

The 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: true

To 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.