Problem description
The x-oss-credential field is missing from the request.
Causes
The request uses a V4 signature, but the x-oss-credential field is absent from the query string.
Examples
The following request uses a V4 presigned URL but is missing x-oss-credential:
GET /oss.jpg?x-oss-signature-verion=OSS4-HMAC-SHA256&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-credential field is required. Its value must use the following format: <AccessKeyId>/<SignDate>/<Region>/oss/aliyun_v4_request.
Solutions
Include all required query parameters in the presigned URL. The following table lists the required and optional parameters for a V4 presigned request:
| Parameter | Required | Description | Example value |
|---|---|---|---|
x-oss-signature-verion | Yes | Signature algorithm identifier | OSS4-HMAC-SHA256 |
x-oss-credential | Yes | Credential scope: access key ID, signing date, region, service, and request type | <AccessKeyId>/<SignDate>/<Region>/oss/aliyun_v4_request |
x-oss-expires | Yes | URL validity period | 1141889120 |
x-oss-signature | Yes | Computed request signature | — |
x-oss-additional-headers | No | Additional headers included in the signature calculation | host |
The value of x-oss-credential uses the following format:
<AccessKeyId>/<SignDate>/<Region>/oss/aliyun_v4_requestFor example: LTAI****************/20221220/cn-hangzhou/oss/aliyun_v4_request
The following example shows a corrected request with all required parameters:
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 server returns a response containing the StringToSign parameter, verify that its value matches the string you used before computing the signature.
References
Use Alibaba Cloud SDKs to construct V4 signature requests: Overview
Calculate the V4 signature manually: Calculate V4 signature by using OSS SDK for Python
V1 signature overview: Overview