0002-00000404

更新时间:
复制 MD 格式

The Credential field in the Authorization request header is incomplete.

Problem description

The Credential field in the Authorization request header is incomplete.

Causes

This error occurs when using the S3-compatible API with AWS Signature Version 4 (SigV4). The Credential field in the Authorization header is missing one or more required components.

The Credential field must follow this format:

<Access-Key-ID>/<date>/<region>/<service>/aws4_request
ComponentDescription
<Access-Key-ID>Your Alibaba Cloud Access Key ID
<date>Signature date in YYYYMMDD format. Must match the date in the x-amz-date header.
<region>The region identifier, for example, us-east-1
<service>The service identifier. Always s3 for S3-compatible requests.
aws4_requestThe termination string. Always the literal value aws4_request.

Examples

The following request fails because the YYYYMMDD date component is missing from the Credential field:

GET /test.txt HTTP/1.0
Date: Tue, 20 Dec 2022 08:48:18 GMT
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
Authorization:AWS4-HMAC-SHA256 Credential=LTAI****************/us-east-1/s3/aws4_request,SignedHeaders=host;x-amz-content-sha256;x-amz-date,Signature=ab2s********************
x-amz-content-sha256: abc****
x-amz-date: 20221220T084818Z
x-oss-s3-compat: true

The Credential value LTAI****************/us-east-1/s3/aws4_request is missing /20221220 between the Access Key ID and the region.

Solutions

Make sure the Credential field includes all required components in the correct order. The following corrected request includes the date 20221220:

GET /test.txt HTTP/1.0
Date: Tue, 20 Dec 2022 08:48:18 GMT
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
Authorization:AWS4-HMAC-SHA256 Credential=LTAI****************/20221220/us-east-1/s3/aws4_request,SignedHeaders=host;x-amz-content-sha256;x-amz-date,Signature=ab2s********************
x-amz-content-sha256: abc****
x-amz-date: 20221220T084818Z
x-oss-s3-compat: true

To avoid manual signing errors, use an Amazon S3 SDK to construct and send requests. For more information, see Use Amazon S3 SDKs to access OSS.