Problem description
The value of the x-oss-credential field in the request is invalid.
Causes
The request uses the V4 signature (OSS4-HMAC-SHA256), but the x-oss-credential field does not follow the required format.
The field must be constructed as:
| Segment | Description | Constraints |
|---|---|---|
<AccessKeyId> | Your Alibaba Cloud AccessKey ID | — |
<SignDate> | The signing date | YYYYMMDD format (compact, no hyphens) |
<Region> | The OSS region code | Lowercase, e.g. cn-hangzhou |
oss | The service identifier | Fixed value, always lowercase |
aliyun_v4_request | Termination string | Fixed value, always lowercase |
The five segments are joined with forward slashes (/):
<AccessKeyId>/<SignDate>/<Region>/oss/aliyun_v4_requestExamples
The following request contains an invalid x-oss-credential value. The credential ends with /abc instead of the required termination string /aliyun_v4_request.
GET /oss.jpg?x-oss-signature-verion=OSS4-HMAC-SHA256&x-oss-credential=AK**ID/2022-12-20/cn-hangzhou/oss/abc&x-oss-expires=1141889120&x-oss-additional-headers=host&x-oss-signature=8u**a3 HTTP/1.1
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
Date: Tue, 20 Dec 2022 08:48:18 GMTSolutions
Replace the invalid termination string at the end of x-oss-credential with aliyun_v4_request:
GET /oss.jpg?x-oss-signature-verion=OSS4-HMAC-SHA256&x-oss-credential=LTAI****************/20221220/cn-hangzhou/oss/aliyun_v4_request&x-oss-expires=1141889120&x-oss-additional-headers=host&x-oss-signature=8u**a3 HTTP/1.1
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
Date: Tue, 20 Dec 2022 08:48:18 GMTIf the error persists, check the StringToSign value. When the server returns a response that contains the StringToSign parameter, verify that the StringToSign value on the server matches the string you computed before signing.
References
To use Alibaba Cloud SDKs to send V4 signature requests, see Overview.
To calculate the V4 signature manually, see Calculate V4 signature by using OSS SDK for Python.
For the V1 signature scheme, see Overview.