[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-03。"],[],[],null,["# V2 Signing Process\n\n| **Important:** This page covers legacy material related to the V2 signing process. It is recommended that users work with the [V4 signing process](/storage/docs/access-control/signed-urls) instead.\n\nThis page provides an overview of signed URLs when working with the V2 signing\nprocess, which is a mechanism for query\nstring authentication for buckets and objects.\nSigned URLs provide a way to give time-limited read or write access to anyone\nin possession of the URL, regardless of whether they have a user account.\n| **Important:** Signed URLs can only be used to access resources in Cloud Storage through [XML API endpoints](/storage/docs/request-endpoints).\n\nComponents of the string that requires signing\n----------------------------------------------\n\nWhen creating a signed URL using a program, your program constructs a string\nthat will be signed. This string should be defined in your program as: \n\n```\nStringToSign = HTTP_Verb + \"\\n\" +\n Content_MD5 + \"\\n\" +\n Content_Type + \"\\n\" +\n Expires + \"\\n\" +\n Canonicalized_Extension_Headers +\n Canonicalized_Resource\n```\n\nThe components that make up this structure are described in the following table:\n\n| **Note:** Query String Parameters like `response-content-disposition` and `response-content-type` are not verified by the signature. To force a `Content-Disposition` or `Content-Type` in the response, [set those parameters in the object metadata](/storage/docs/viewing-editing-metadata#edit).\n\nSigning strings with the App Engine App Identity service\n--------------------------------------------------------\n\nWhen creating a signed URL using a program, you can either sign the string\nfrom within your program, or else from\nwithin a App Engine application using the App Engine Identity service,\nwhich uses App Engine's service account credentials. For example, using the\n[Python App Identity API](/appengine/docs/python/appidentity), you can:\n\n- Use `google.appengine.api.app_identity.sign_blob()` to sign the bytes from\n your constructed string, providing the `Signature` you need when\n assembling the signed URL.\n\n- Use `google.appengine.api.app_identity.get_service_account_name()`\n to retrieve a service account name, which is the `GoogleAccessId` you need\n when assembling the signed URL.\n\nFor support in other languages, see\n[App Identity API for Java Overview](/appengine/docs/java/appidentity),\n[App Identity API for PHP Overview](/appengine/docs/php/appidentity),\nand [App Identity Go Functions](/appengine/docs/go/appidentity).\n\nThe App Identity service rotates the private keys when it signs blobs. Signed URLs\ngenerated from the App Identity service are good for at least one hour, and are best used for\nshort-lived access to resources.\n\nCanonical extension headers\n---------------------------\n\nWhen creating a signed URL using a program, you construct the Canonical\nExtension Headers portion of the message by concatenating all\nextension (custom) headers that begin with `x-goog-`. However, you cannot perform a simple\nconcatenation. Keep the following algorithm in mind as you create the headers:\n\n1. Make all custom header names lowercase.\n\n2. Sort all custom headers by header name using a lexicographical sort by code point value.\n\n3. If present, remove the `x-goog-encryption-key` and `x-goog-encryption-key-sha256`\n headers. These headers contain sensitive information that must not be included\n in the string-to-sign; however, these headers must still be used in any\n requests that use the generated signed URL.\n\n4. Eliminate duplicate header names by creating one header name with a comma-separated list of\n values. Be sure there is no whitespace between the values, and be sure that the order of the\n comma-separated list matches the order that the headers appear in your request. For more\n information, see [RFC 7230 section 3.2](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2).\n\n5. Replace any folding whitespace or newlines (CRLF or LF) with a single space. For more\n information about folding whitespace, see\n [RFC 7230, section 3.2.4.](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4).\n\n6. Remove any whitespace around the colon that appears after the header name.\n\n7. Append a newline \"\\\\n\" (U+000A) to each custom header.\n\n8. Concatenate all custom headers.\n\n| **Important:** You must use both the header name and the header value when you construct the Canonical Extension Headers portion of the query string. Be sure to remove any whitespace around the colon that separates the header name and value. For example, using the custom header `x-goog-acl: private` without removing the space after the colon returns a `403 Forbidden` error, because the request signature you calculate does not match the signature Cloud Storage calculates.\n\nCanonical resources\n-------------------\n\nWhen creating a signed URL using a program, you construct the\nCanonicalized Resource portion of the message by concatenating the resource\npath (bucket and object and subresource) that the request is acting on. Keep\nthe following in mind as you create the resource:\n\n- The canonical resource is everything that follows the host name. For example,\n if the Cloud Storage URL is `https://storage.googleapis.com/example-bucket/cat-pics/tabby.jpeg`,\n then the canonical resource is `/example-bucket/cat-pics/tabby.jpeg`.\n\n- If the request is scoped to a subresource, such as `?cors`, add this subresource,\n including the question mark, to the end of the string.\n\n- Be sure to copy the HTTP request path literally: that is, you should include all URL encoding\n (percent signs) in the string that you create. Also, be sure that you include only query string\n parameters that designate subresources (such as `cors`). You should not include query string\n parameters such as `?prefix`, `?max-keys`, `?marker`, and `?delimiter`."]]