A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cloud.google.com/storage/docs/authentication/managing-hmackeys below:

Manage HMAC keys for service accounts | Cloud Storage

Skip to main content Manage HMAC keys for service accounts

Stay organized with collections Save and categorize content based on your preferences.

Overview

This page shows you how to create, disable, and delete Hash-based Message Authentication Code (HMAC) keys associated with service accounts in your project.

Before you begin

Before using this feature in Cloud Storage, you must meet the following requirements:

  1. Have sufficient permission to work with HMAC keys in the selected project:

  2. Have a service account in your project that you intend to create HMAC keys for. See Creating a service account if you don't currently have one.

  3. Make sure the following organization policy constraints are disabled:

    See Creating and managing organization policies for instructions on how to check and disable constraints.

Create an HMAC key Important: When you create an HMAC key, you are given the secret for that key, which you must store securely. If you lose the secret, you are no longer able to use the HMAC key to authorize requests.

To create an HMAC key for a service account:

Console
  1. In the Google Cloud console, go to the Cloud Storage Settings page.

    Go to Settings

  2. Select the Interoperability tab.

  3. Click add_box Create a key for a service account.

  4. Select the service account you want the HMAC key to be associated with.

  5. Click Create key.

To learn how to get detailed error information about failed Cloud Storage operations in the Google Cloud console, see Troubleshooting.

Command line

Use the hmac create command:

gcloud storage hmac create SERVICE_ACCOUNT_EMAIL

Where SERVICE_ACCOUNT_EMAIL is the email address associated with your service account. For example, example-service-account@my-pet-project.iam.gserviceaccount.com.

If successful, the response contains an HMAC key resource, including values for the accessId and secret.

Client libraries C++

For more information, see the Cloud Storage C++ API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

C#

For more information, see the Cloud Storage C# API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

Go

For more information, see the Cloud Storage Go API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

Java

For more information, see the Cloud Storage Java API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

Node.js

For more information, see the Cloud Storage Node.js API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

PHP

For more information, see the Cloud Storage PHP API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

Python

For more information, see the Cloud Storage Python API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

Ruby

For more information, see the Cloud Storage Ruby API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

Terraform

You can use a Terraform resource to create an HMAC key. This sample also includes a resource to create a service account.

REST APIs JSON API
  1. Have gcloud CLI installed and initialized, which lets you generate an access token for the Authorization header.

  2. Use cURL to call the JSON API with a POST hmacKeys request:

    curl -X POST \
      -H "Authorization: Bearer $(gcloud auth print-access-token)" \
      "https://storage.googleapis.com/storage/v1/projects/PROJECT_IDENTIFIER/hmacKeys?serviceAccountEmail=SERVICE_ACCOUNT_EMAIL"

    Where:

XML API
  1. Have gcloud CLI installed and initialized, which lets you generate an access token for the Authorization header.

  2. Use cURL to call the XML API with a POST HMAC Key request:

    curl -X POST \
      -H "Authorization: Bearer $(gcloud auth print-access-token)" \
      "https://storage.googleapis.com/?Action=CreateAccessKey&UserName=SERVICE_ACCOUNT_EMAIL"

    Where SERVICE_ACCOUNT_EMAIL is the email address associated with your service account. For example, example-service-account@my-pet-project.iam.gserviceaccount.com.

Note: After creation, it can take up to 60 seconds for a service account HMAC key to become useable. Get HMAC key information

To list the HMAC keys for a project, and get information about the keys:

Console
  1. In the Google Cloud console, go to the Cloud Storage Settings page.

    Go to Settings

  2. Select the Interoperability tab.

    Service accounts that have HMAC keys associated with them appear in the Access keys for service accounts subsection of the Service account HMAC section.

  3. Click the name of a specific service account to see the HMAC keys associated with it and the status of those keys.

Command line
  1. Use the hmac list command to list hmac keys in your project:

    gcloud storage hmac list

    If successful, the command returns a list of hmac key access IDs, along with the state of each key and the service account associated with each key.

  2. Use the hmac describe command to retrieve metadata for a specific key:

    gcloud storage hmac describe KEY_ACCESS_ID 

    Where KEY_ACCESS_ID is the access ID for the desired key.

Client libraries C++

For more information, see the Cloud Storage C++ API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

The following sample retrieves a list of HMAC keys associated with a project:

The following sample retrieves information for a specific HMAC key:

C#

For more information, see the Cloud Storage C# API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

The following sample retrieves a list of HMAC keys associated with a project:

The following sample retrieves information for a specific HMAC key:

Go

For more information, see the Cloud Storage Go API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

The following sample retrieves a list of HMAC keys associated with a project:

The following sample retrieves information for a specific HMAC key:

Java

For more information, see the Cloud Storage Java API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

The following sample retrieves a list of HMAC keys associated with a project:

The following sample retrieves information for a specific HMAC key:

Node.js

For more information, see the Cloud Storage Node.js API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

The following sample retrieves a list of HMAC keys associated with a project:

The following sample retrieves information for a specific HMAC key:

PHP

For more information, see the Cloud Storage PHP API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

The following sample retrieves a list of HMAC keys associated with a project:

The following sample retrieves information for a specific HMAC key:

Python

For more information, see the Cloud Storage Python API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

The following sample retrieves a list of HMAC keys associated with a project:

The following sample retrieves information for a specific HMAC key:

Ruby

For more information, see the Cloud Storage Ruby API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

The following sample retrieves a list of HMAC keys associated with a project:

The following sample retrieves information for a specific HMAC key:

REST APIs Update the state of an HMAC key

To switch an HMAC key between being active and inactive:

Console
  1. In the Google Cloud console, go to the Cloud Storage Settings page.

    Go to Settings

  2. Select the Interoperability tab.

  3. In the Access keys for service accounts subsection, click the name of the service account associated with the HMAC key whose status you want to update.

  4. Click the status of the key you want to update.

Command line

Use the hmac update command:

gcloud storage hmac update ACCESS_KEY_ID STATE

Where:

If successful, the command returns the updated metadata of the HMAC key.

Client libraries C++

For more information, see the Cloud Storage C++ API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

The following sample deactivates an HMAC key:

The following sample activates an HMAC key:

C#

For more information, see the Cloud Storage C# API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

The following sample deactivates an HMAC key:

The following sample activates an HMAC key:

Go

For more information, see the Cloud Storage Go API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

The following sample deactivates an HMAC key:

The following sample activates an HMAC key:

Java

For more information, see the Cloud Storage Java API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

The following sample deactivates an HMAC key:

The following sample activates an HMAC key:

Node.js

For more information, see the Cloud Storage Node.js API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

The following sample deactivates an HMAC key:

The following sample activates an HMAC key:

PHP

For more information, see the Cloud Storage PHP API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

The following sample deactivates an HMAC key:

The following sample activates an HMAC key:

Python

For more information, see the Cloud Storage Python API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

The following sample deactivates an HMAC key:

The following sample activates an HMAC key:

Ruby

For more information, see the Cloud Storage Ruby API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

The following sample deactivates an HMAC key:

The following sample activates an HMAC key:

REST APIs

When you change the state of an HMAC key, it takes up to 3 minutes for the state change to propagate through the Cloud Storage system. For this reason, you should wait at least 3 minutes between making an HMAC key inactive and deleting the key.

Delete an HMAC key Caution: HMAC keys cannot be recovered once you delete them. If you want to keep an HMAC key but prevent it from being used, set its state to INACTIVE.

An HMAC key must be in an inactive state in order to delete it. To delete an inactive HMAC key:

Console
  1. In the Google Cloud console, go to the Cloud Storage Settings page.

    Go to Settings

  2. Select the Interoperability tab.

  3. In the Access keys for service accounts subsection, click the name of the service account associated with the HMAC key you want to delete.

  4. Click the Trash icon associated with the key you want to delete.

  5. In the dialog that appears, enter the first 10 characters of the access key ID as they are given in the window.

  6. Click Delete.

Command line

Use the hmac delete command:

gcloud storage hmac delete ACCESS_KEY_ID

Where ACCESS_KEY_ID is the access ID associated with the key you are deleting.

If successful, the command does not return a response.

Client libraries C++

For more information, see the Cloud Storage C++ API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

C#

For more information, see the Cloud Storage C# API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

Go

For more information, see the Cloud Storage Go API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

Java

For more information, see the Cloud Storage Java API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

Node.js

For more information, see the Cloud Storage Node.js API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

PHP

For more information, see the Cloud Storage PHP API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

Python

For more information, see the Cloud Storage Python API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

Ruby

For more information, see the Cloud Storage Ruby API reference documentation.

To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.

REST APIs What's next

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-10-02 UTC.

[[["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-10-02 UTC."],[],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.5