Cloud Tasks Client Libraries

This page shows how to get started with the Cloud Client Libraries for the Cloud Tasks API. Read more about the client libraries for Cloud APIs in Client Libraries Explained.

Installing the client library


For more information, see Setting Up a C# Development Environment.

Install-Package Google.Cloud.Tasks.V2 -Version 1.0.0


For more information, see Setting Up Your Development Environment.

go get -u


For more information, see Setting Up a Java Development Environment.

If you are using Maven, add the following to your pom.xml file:


If you are using Gradle, add the following to your dependencies:

compile ''

If you are using SBT, add the following to your dependencies:

libraryDependencies += "" % "google-cloud-tasks" % "1.29.1"

If you are using VS Code, IntelliJ or Eclipse, you can add client libraries to your project using the following IDE plugins:

The plugins provide additional functionality, such as key management for service accounts. Refer to each plugin's documentation for details.


For more information, see Setting Up a Node.js Development Environment.

npm install --save @google-cloud/tasks


composer require google/cloud-tasks


For more information, see Setting Up a Python Development Environment.

pip install --upgrade google-cloud-tasks


For more information, see Setting Up a Ruby Development Environment.

gem install google-cloud-tasks

Setting up authentication for use with the client library

To run the client library, you must first set up authentication by creating a service account with its key, and then setting an environment variable to point to that key. For more information, see the GCP authentication documentation .

Cloud Console


  1. 在 Cloud Console 中,转到创建服务帐号页面。

  2. 选择一个项目。
  3. 服务帐号名称字段中,输入一个名称。 Cloud Console 会根据此名称填充服务帐号 ID 字段。

    服务帐号说明字段中,输入说明。例如,Service account for quickstart

  4. 点击创建
  5. 点击选择角色字段。


  6. 点击继续
  7. 点击完成以完成服务帐号的创建过程。



  1. 在 Cloud Console 中,点击您创建的服务帐号的电子邮件地址。
  2. 点击密钥
  3. 依次点击添加密钥创建新密钥
  4. 点击创建。JSON 密钥文件将下载到您的计算机上。
  5. 点击关闭


您可以使用本地机器上的 Cloud SDK 或在 Cloud Shell 中运行以下命令。

  1. 创建服务帐号。将 NAME 替换为服务帐号的名称。

    gcloud iam service-accounts create NAME
  2. 向服务帐号授予权限。将 PROJECT_ID 替换为您的项目 ID。

    gcloud projects add-iam-policy-binding PROJECT_ID --member="" --role="roles/owner"
  3. 生成密钥文件。将 FILE_NAME 替换为密钥文件的名称。

    gcloud iam service-accounts keys create FILE_NAME.json

将环境变量 GOOGLE_APPLICATION_CREDENTIALS 设置为包含您的服务帐号密钥的 JSON 文件的路径。 此变量仅适用于当前的 shell 会话,因此,如果您打开新的会话,请重新设置该变量。

Using the client library

For examples of using the client library, see Creating HTTP Target Tasks or Creating App Engine Tasks

Additional resources