Prepare and test your skills
Prepare and test your skills
Application Default Credentials (ADC) (opens in a new tab) is the standard way for Google API client libraries to find credentials automatically without hard-coded keys. When code runs on a developer workstation, ADC checks the local credential file for user credentials. When code runs on Google Cloud, ADC checks the service account attached to the compute resource. Authorization then depends on the Identity and Access Management (IAM) permissions granted to that user account or service account.
Setting up ADC for local development creates user-based credentials that client libraries can reuse for API calls. The setup starts with installing the Google Cloud CLI (gcloud CLI) and running gcloud init to configure the project and defaults. Users with an external identity provider must first sign in with their federated identity before this step. The developer then runs gcloud auth application-default login, which opens a browser sign-in screen and stores credentials in the local credential file used by ADC. Cloud Shell already provides its own credentials, so this login step is not needed there.
Authorizing REST requests from the command line means reusing gcloud CLI credentials to make direct calls to Google Cloud API endpoints. The shell runs gcloud auth print-access-token to output a short-lived access token for the signed-in identity. That token is inserted into the request as an Authorization: Bearer header for tools such as curl or PowerShell. The request then flows from the local shell or Cloud Shell to the Google Cloud API endpoint, such as https://iam.googleapis.com/v1/projects/PROJECT_ID/serviceAccounts to list service accounts. The same pattern works for curl on Linux, macOS, or Cloud Shell and for Invoke-WebRequest in PowerShell on Windows.
Service account impersonation lets a developer authenticate locally as a service account without downloading its long-lived key. Impersonation is used when user credentials are not feasible or when testing the exact permissions assigned to a service account. The caller must have the iam.serviceAccounts.getAccessToken permission, which is included in the Service Account Token Creator role (roles/iam.serviceAccountTokenCreator). Two gcloud CLI configurations enable impersonation for different uses, and each configuration directs a different layer to act as the service account.
The two impersonation configurations target gcloud CLI calls and client-library ADC files:
gcloud config set auth/impersonate_service_account makes gcloud CLI calls act as the specified service accountgcloud auth application-default login --impersonate-service-account creates a local ADC file that client libraries use for authorizationThe ADC-file approach with impersonation is supported only for Go, Java, Node.js, and Python.
Authentication for a workload running on Google Cloud uses the credentials of the service account attached to the compute resource where the code runs. A common example is code running on a Compute Engine virtual machine (VM) instance using the instance service account. This attached-service-account approach is the preferred method for Google Cloud compute resources because no local credential file is managed or distributed. For most services, the service account must be attached when the resource is created and cannot be added or replaced later, while Compute Engine allows a service account to be attached to a VM instance at any time.
Exam tip: Attach the service account at resource creation time for most Google Cloud services, because only Compute Engine lets you attach a service account to an existing VM instance.
Selection of a library type means choosing between Cloud Client Libraries (opens in a new tab) and Google API Client Libraries for programmatic access to Google Cloud services. Cloud Client Libraries are the latest and recommended suite for calling Google Cloud APIs, while Google API Client Libraries are pre-built libraries that can also interact with those APIs. The choice depends on language support, service coverage, and whether an idiomatic, high-level interface exists for the target service.
Cloud Client Libraries are the recommended, idiomatic libraries for accessing Google Cloud services programmatically. They use each supported language's natural conventions and styles and provide high-level abstractions built around service metaphors. These abstractions hide low-level implementation details and raw service API concepts so developers write less boilerplate code. Because the libraries embrace language idioms and work with the standard library, they integrate cleanly with existing code.
Cloud Client Libraries are published for individual Google Cloud services in each supported language. Coverage must be checked per language and per service through the GitHub repository and library reference for that language. Supported languages include:
Google API Client Libraries are pre-built client libraries for interacting with Google APIs, including Google Cloud services such as the App Engine Admin API. Any of these libraries can be used to call a supported API, and several languages have service-specific pages or instructions to help developers get started. For code-free experimentation, requests can be tried in the Google APIs Explorer before writing code. A custom client can also be built with the Google API Discovery Service and the discovery document for an API.
In the Discovery Service flow, the Discovery Service reads the API's discovery document, such as the discovery document for the App Engine Admin API. That machine-readable description is then used to build the client library for the target language. This path is useful when a pre-built idiomatic library is not available for the needed language or service. The generated client still calls the same underlying API endpoint as the other library suites.
Choosing the appropriate suite starts with checking whether a Cloud Client Libraries package exists for the target language and service combination. When that package exists, it is the preferred choice because it offers idiomatic design, service-metaphor abstractions, and reduced boilerplate. When it does not exist, or when working with a broader Google API surface, a Google API Client Library or Discovery-built client provides the fallback path. Both paths reach the same underlying API, but the developer experience is different.
A decision tree that checks if a Cloud Client Library exists for the language and service to choose between the recommended idiomatic library and the Google API Client Library fallback.
| Library suite | Design approach | Developer experience |
|---|---|---|
| Cloud Client Libraries | Idiomatic, high-level abstractions organized around service metaphors | Follows language conventions, works with the standard library, and reduces boilerplate code |
| Google API Client Libraries | Pre-built libraries or clients built from an API discovery document through the Google API Discovery Service | Exposes the underlying API surface and supports many programming languages |
Exam tip: Cloud Client Libraries are the recommended choice when available for the language and service; use Google API Client Libraries when that idiomatic package is not available or when building directly from a discovery document.
Operational Robustness and Error Management is the practice of keeping applications that call Google Cloud APIs reliable under transient failures, quota limits, and large request volumes. Cloud Client Libraries (opens in a new tab) are the recommended way to build this reliability because they reduce boilerplate code and take over routine operational work. The application sends requests to Cloud API endpoints, and the library manages authentication, secure transport, retries, and validation between the application and the API. Robust operation also depends on efficient session reuse, predictable dependencies, and monitoring of traffic and errors.
Cloud Client Libraries handle routine operational work so application code can focus on business logic. When the application makes a call, the library communicates with the server, applies authentication, and encrypts traffic in transit with TLS. This handling covers the full path from the application process to the googleapis.com endpoint over the public internet or Virtual Private Cloud (VPC) networks. Because the library owns these steps, retry behavior and secure transport do not have to be rebuilt for every call.
The common processes handled by the libraries include:
Reusing client objects means creating one session client and using that same instance for many requests instead of creating a new client per request. Requests from the same instance share authentication credential instances, so the application avoids repeating expensive setup work. Creating too many separate clients in a short period can trigger rate limiting on authentication and cause requests to fail authentication. Reuse therefore protects both performance and reliability.
The first request on a new session client performs authentication, authorization, and access token generation over the network, which can take multiple seconds. The session client then reuses the same access token for later calls for as long as the token is valid, typically one hour. Only after the token expires does the session client refresh the access token automatically, so one long-lived instance can serve all requests that run under the same credentials.
Exam tip: Reuse the same session client instance for all requests under the same credentials; creating a new client per request repeats authentication and risks auth rate limiting.
Keeping production dependencies predictable means pinning library versions and staying current with releases. Cloud Client Libraries and Google API Client Libraries are installed with package managers such as npm and pip, and pinning uses built-in versioning so builds consistently use the same library versions. Pinning is especially important for beta clients, where the API surface can change between releases. Staying up to date means upgrading libraries as Google Cloud capabilities and APIs change, since many libraries release often and support semantic versioning.
If an application shows degraded performance or errors on an older library version, upgrading takes advantage of improvements in newer versions. This balance of pinned builds plus planned upgrades keeps error behavior and retry handling stable in production. Predictable versions also make troubleshooting easier because every deployment uses the same tested library behavior.
Monitoring API usage means tracking how a project uses each Cloud API so problems can be triaged quickly. Most Cloud APIs report detailed usage for the project, and the API Dashboard in the Google Cloud console shows traffic levels, error rates, and latencies for that API. Cloud Monitoring depends on that usage data to build custom dashboards and alerts, so a rise in error rates or latency can trigger investigation. Early alerts help prevent localized failures from spreading across integration workflows.
Capping usage means respecting the rate limits and resource quotas that all Cloud APIs enforce for fair use and abuse protection. Quotas also control spending, because an application can lower its own quota limits and higher limits require a quota increase request. Billing and quota attribution depends on the API type: a resource-based API uses the project associated with the resources being accessed, while a client-based API uses the project associated with the client accessing the resources.
iam.serviceAccounts.getAccessToken permission and supports an ADC-file approach only for Go, Java, Node.js, and Python client libraries.Application Default Credentials (ADC) is the standard way for Google API client libraries to find credentials automatically without hard-coded keys. When code runs on a developer workstation ADC checks the local credential file for user credentials, and when code runs on Google Cloud ADC checks the service account attached to the compute resource. Authorization then depends on the Identity and Access Management (IAM) permissions granted to that user account or service account.
Cloud Client Libraries are the recommended, idiomatic libraries when a package exists for the target language and service combination because they offer high-level abstractions organized around service metaphors and reduce boilerplate code. When that package does not exist, or when working with a broader Google API surface, a Google API Client Library or a client built from an API discovery document through the Google API Discovery Service provides the fallback path. Both paths reach the same underlying API, but the developer experience is different.
Service account impersonation lets a developer authenticate locally as a service account without downloading its long-lived key and is used when user credentials are not feasible or when testing the exact permissions assigned to a service account. The caller must have the iam.serviceAccounts.getAccessToken permission, which is included in the Service Account Token Creator role. The local ADC file approach for client-library authorization with impersonation is supported only for Go, Java, Node.js, and Python.
Reusing the same session client instance means requests share authentication credential instances and the same access token for as long as the token is valid, typically one hour. The first request performs authentication, authorization, and access token generation over the network which can take multiple seconds, and the client refreshes the token automatically only after it expires. Creating too many separate clients in a short period can trigger rate limiting on authentication and cause requests to fail authentication.
Your development team is building high-throughput backend microservices that programmatically manage and stream data across several Google Cloud services, including Pub/Sub and Dataproc.
The team needs to establish coding and dependency standards with the following architectural requirements:
Which library selection strategy should you recommend?
Generate custom gRPC client stubs from protocol buffers for all services as the primary choice, bypassing pre-built client libraries.
Standardize exclusively on Google API Client Libraries across all services to ensure uniform REST/JSON transport and avoid gRPC protocol dependencies.
Use raw HTTP/REST requests constructed with language-standard HTTP clients to avoid library versioning and dependency pinning issues.
Adopt Cloud Client Libraries as the default standard, and fall back to Google API Client Libraries only when a service or language is unsupported by Cloud Client Libraries.
Last updated