Stay organized with collections
Save and categorize content based on your preferences.
This page shows you how to use the Google Cloud signBlob method
to create a signature from a string-to-sign or policy document. Signatures
are used as credentials in certains requests, such as signed URLs. This
guide uses RSA keys for creating signatures.
You must have the iam.serviceAccounts.signBlob permission for the service
account that you use in this guide. The iam.serviceAccounts.signBlob
permission is included in the roles/iam.serviceAccountTokenCreator role.
The service account that you use in this guide must have permission to
perform the request encoded within the signature. For example, if the
signature will be used to read object data from a bucket, the service
account must have permission to read the object data.
JSON_FILE_NAME is the name of the file you created
in Step 2.
SERVICE_ACCOUNT_EMAIL is the email address of the
service account you want to use to create the signature. For example,
service-7550275089395@my-pet-project.iam.gserviceaccount.com.
If successful, a message digest is returned in the signedBlob field in
the response, which is base64 encoded.
To complete the signature, ensure the message digest is base64 decoded, and
then hex-encode the message digest.
What's next
See the reference page for signing blobs with the Google Cloud CLI.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[],[],null,["# Create signatures\n\nThis page shows you how to use the [Google Cloud `signBlob` method](/iam/docs/reference/credentials/rest/v1/projects.serviceAccounts/signBlob)\nto create a [signature](/storage/docs/authentication/signatures) from a string-to-sign or policy document. Signatures\nare used as credentials in certains requests, such as [signed URLs](/storage/docs/access-control/signed-urls). This\nguide uses RSA keys for creating signatures.\n| **Important:** The [Google-managed service account keys](/iam/docs/service-account-creds#google-managed-keys) used by the `signBlob` method are rotated regularly. If you set an expiration time for a signature that is greater than 12 hours and generate the signature using the `signBlob` method, the signature is usable for at least 12 hours, but might stop working prior to the expiration time due to key rotation. Signatures generated using the `signBlob` method are best used for short-lived access to resources.\n\nBefore you begin\n----------------\n\n1.\n\n\n Enable the Service Account Credentials API.\n\n\n [Enable the API](https://console.cloud.google.com/flows/enableapi?apiid=iamcredentials.googleapis.com&redirect=https://console.cloud.google.com)\n\n \u003cbr /\u003e\n\n2. You must have the `iam.serviceAccounts.signBlob` permission for the service\n account that you use in this guide. The `iam.serviceAccounts.signBlob`\n permission is included in the `roles/iam.serviceAccountTokenCreator` role.\n\n3. The service account that you use in this guide must have permission to\n perform the request encoded within the signature. For example, if the\n signature will be used to read object data from a bucket, the service\n account must have permission to read the object data.\n\nCreate a signature\n------------------\n\n1. Have gcloud CLI [installed and initialized](/sdk/docs/install), which lets\n you generate an access token for the `Authorization` header.\n\n\n2. Create a JSON file that contains the following information:\n\n\n ```json\n {\n \"payload\": \"\u003cvar translate=\"no\"\u003eREQUEST_INFORMATION\u003c/var\u003e\"\n }\n ```\n\n\n Where:\n\n\n - \u003cvar translate=\"no\"\u003eREQUEST_INFORMATION\u003c/var\u003e is a [string-to-sign](/storage/docs/authentication/signatures#string-to-sign) or a [policy document](/storage/docs/authentication/signatures#policy-document). For both, content must be base64-encoded.\n3. Use [`cURL`](http://curl.haxx.se/) to call the IAM API with a\n [`signBlob`](/iam/docs/reference/credentials/rest/v1/projects.serviceAccounts/signBlob) request:\n\n ```\n curl -X POST --data-binary @JSON_FILE_NAME \\\n -H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n -H \"Content-Type: application/json\" \\\n \"https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/SERVICE_ACCOUNT_EMAIL:signBlob\"\n ```\n\n Where:\n - \u003cvar translate=\"no\"\u003eJSON_FILE_NAME\u003c/var\u003e is the name of the file you created\n in Step 2.\n\n - \u003cvar translate=\"no\"\u003eSERVICE_ACCOUNT_EMAIL\u003c/var\u003e is the email address of the\n service account you want to use to create the signature. For example,\n `service-7550275089395@my-pet-project.iam.gserviceaccount.com`.\n\n If successful, a *message digest* is returned in the `signedBlob` field in\n the response, which is base64 encoded.\n4. To complete the signature, ensure the message digest is base64 decoded, and\n then hex-encode the message digest.\n\nWhat's next\n-----------\n\n- See the reference page for signing blobs with the [Google Cloud CLI](/sdk/gcloud/reference/iam/service-accounts/sign-blob).\n- [Create a signed URL manually](/storage/docs/access-control/signing-urls-manually), using the signature you created.\n- [Create a signed URL with Google Cloud tools](/storage/docs/access-control/signing-urls-with-helpers).\n- Learn more about [signatures](/storage/docs/authentication/signatures)."]]