Problem description
The value of the X-Amz-Credential field in the request is invalid.
Causes
The request uses an Amazon S3-compatible Signature Version 4 (SigV4), but the value of X-Amz-Credential does not match the required format.
X-Amz-Credential must follow this format:
<AccessKey-ID>/YYYYMMDD/REGION/SERVICE/aws4_request| Segment | Description | Example |
|---|---|---|
<AccessKey-ID> | Your Alibaba Cloud AccessKey ID | LTAI**************** |
YYYYMMDD | The date of the request in UTC, formatted as YYYYMMDD | 20221220 |
REGION | The region identifier, must be all lowercase | us-east-1 |
SERVICE | The service identifier, must be all lowercase | s3 |
aws4_request | Fixed termination string, must be all lowercase | aws4_request |
Examples
The following request fails because the X-Amz-Credential value is invalid:
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=ab2***st HTTP/1.0
Date: Tue, 20 Dec 2022 08:48:18 GMT
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
x-oss-s3-compat: trueSolutions
Set X-Amz-Credential to a valid value, then verify that all other signature fields are present and correct.
Valid credential example:
X-Amz-Credential=LTAI****************/20221220/us-east-1/s3/aws4_requestThe following request includes a correctly formatted X-Amz-Credential:
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 constructing SigV4 requests manually, use Amazon S3 SDKs to access OSS. For more information, see Use Amazon S3 SDKs to access OSS.
该文章对您有帮助吗?