Problem description
The value of the x-oss-credential field in the request is invalid.
Causes
You initiate a request that uses the V4 signature. However, the value of the x-oss-credential field in the request is invalid.
Examples
The following code provides an example:
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 GMTThe x-oss-signature filed is required. It is used to specify the signature. The x-oss-signature field is in the following format: <AccessKeyId>/<SignDate>/<Region>/oss/aliyun_v4_request. In the preceding example, the value of the x-oss-credential field ends with invalid characters /abc.
Solutions
Replace /abc at the end of the value of the x-oss-credential field with /aliyun_v4_request. The following code provides a correct example:
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 GMTReferences
For information about how to use Alibaba Cloud SDKs to initiate a request that uses the V4 signature, see Overview.
Calculate the signature:
For information about how to calculate the V4 signature, see Calculate V4 signature by using OSS SDK for Python.
For information about how to specify the signature logic based on the V1 signature, see Overview.
If the server returns a response that contains the
StringToSignparameter, you must check whether the value of the StringToSign parameter on the server is the same as the string before calculation.