[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6995P541KVP3JXRCN17FAA8":3,"skill-same:01M6995P541KVP3JXRCN17FAA8":75},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":38,"linkOnly":39,"markdownContent":40,"markdownBody":41,"frontMatter":42,"refName":46,"commitSha":47,"skillDirectory":48,"forksCount":49,"repositoryHtmlUrl":50,"repositoryHomepageUrl":6,"ownerHtmlUrl":51,"ownerBlogUrl":52,"ownerDescription":53,"updatedAt":54,"install":55,"resources":68},"01M6995P541KVP3JXRCN17FAA8","google-cloud-recipe-auth",null,"Provides expert guidance on Identity and Access Management (IAM) and authenticating and authorizing to Google Cloud services and APIs, covering human users, service identities, Application Default Credentials (ADC), and best practices for secure access.","google\u002Fskills","google","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F1342004?v=4","01M698VYEFDM0VJBZDYYJ2T83S","Google","01M698WR0H76ENHE587T9EJT89",24122,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fcloud\u002Fgoogle-cloud-recipe-auth\u002FSKILL.md",[],[19,20,21,9,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],"google cloud recipe auth","google cloud","auth","recipe","cloud","for","users","service","human","expert","default","guidance","access","credentials","iam","services","best practices","secure","identity","2026-11-10 10:12:30",false,"---\nname: google-cloud-recipe-auth\nmetadata:\n  version: \"1.0.2\"\n  category: GettingStarted\ndescription: Provides expert guidance on Identity and Access Management (IAM) and authenticating and authorizing to Google Cloud services and APIs, covering human users, service identities, Application Default Credentials (ADC), and best practices for secure access.\n---\n\n# Authenticating and Authorizing to Google Cloud (IAM)\n\n[Authentication](https:\u002F\u002Fdocs.cloud.google.com\u002Fdocs\u002Fauthentication.md.txt) is the\nprocess of proving **who you are**. In Google Cloud, you represent a\n**Principal** (an identity like a user or a service). This is the first step\nbefore [Authorization](https:\u002F\u002Fdocs.cloud.google.com\u002Fiam\u002Fdocs\u002Foverview.md.txt)\n(determining **what you can do**).\n\n## Attribution\n\n**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you\nMUST read [Usage Attribution](references\u002Fattribution.md). For commands executed\ndirectly in the terminal (never in generated scripts, Terraform, or user code),\nprefix `gcloud` with\n`CLOUDSDK_METRICS_REQUEST_ATTRIBUTION=\"agent-skills\u002F1.0 (skill:google-cloud-recipe-auth)\"`\nand append `agent-skills\u002F1.0 (skill:google-cloud-recipe-auth)` to `User-Agent` headers.\n\n## Authentication\n\n### Clarifying Questions for the Agent\n\nBefore providing a specific solution, clarify the following with the user:\n\n1.  **Who or what is authenticating?** (A human developer, a local script, or an\n    application running in production?)\n2.  **Where is the code running?** (Local laptop, [Compute\n    Engine](https:\u002F\u002Fdocs.cloud.google.com\u002Fcompute\u002Fdocs.md.txt),\n    [GKE](https:\u002F\u002Fdocs.cloud.google.com\u002Fkubernetes-engine\u002Fdocs.md.txt), [Cloud\n    Run](https:\u002F\u002Fdocs.cloud.google.com\u002Frun\u002Fdocs.md.txt), or another cloud like\n    AWS\u002FAzure?)\n3.  **What is the target?** (A Google Cloud API like Storage\u002FBigQuery, or a\n    custom application you built?)\n4.  **Are you using a high-level client library?** (e.g., Python, Go, Node.js\n    libraries usually handle ADC automatically.)\n\n---\n\n## Human Authentication\n\nFor users to access Google Cloud, they need an identity that Google Cloud can\nrecognize.\n\n### Types of User Identities\n\nGoogle Cloud supports several ways to configure identities for your internal\nworkforce (developers, administrators, employees):\n\n*   **[Google-Managed\n    Accounts](https:\u002F\u002Fdocs.cloud.google.com\u002Fiam\u002Fdocs\u002Fuser-identities.md.txt)**:\n    You can use Cloud Identity or Google Workspace to create managed user\n    accounts. These are called managed accounts because your organization\n    controls their lifecycle and configuration.\n*   **[Federation using Cloud Identity or Google\n    Workspace](https:\u002F\u002Fdocs.cloud.google.com\u002Fiam\u002Fdocs\u002Fuser-identities.md.txt)**:\n    You can federate identities to allow users to use their existing identity\n    and credentials to sign in to Google services. Users authenticate against an\n    external identity provider (IdP), but you must keep accounts synchronized\n    into Google Cloud using tools like Google Cloud Directory Sync (GCDS) or an\n    external authoritative source like Active Directory or Microsoft Entra ID.\n*   **[Workforce Identity\n    Federation](https:\u002F\u002Fdocs.cloud.google.com\u002Fiam\u002Fdocs\u002Fuser-identities.md.txt)**:\n    This lets you use an external IdP to authenticate and authorize a workforce\n    using IAM directly. Unlike standard federation, you do not need to\n    synchronize user identities from your existing IdP to Google Cloud\n    identities. It supports syncless, attribute-based single sign-on.\n\n### Methods of Access for Developers and Administrators\n\nUsed for interacting with Google Cloud resources and APIs during development and\nmanagement.\n\n*   **[Google Cloud Console](https:\u002F\u002Fconsole.cloud.google.com\u002F)**: The primary\n    web interface. You authenticate using your Google Account (Gmail or [Google\n    Workspace](https:\u002F\u002Fworkspace.google.com\u002F)).\n*   **[gcloud CLI](https:\u002F\u002Fdocs.cloud.google.com\u002Fsdk\u002Fdocs\u002Finstall-sdk.md.txt) (`gcloud\n    auth login`)**: Used to authenticate the CLI itself so you can run\n    management commands (e.g., `gcloud compute instances list`). It uses a\n    **Credential** (like an OAuth 2.0 refresh token) stored locally.\n*   **Local Development with [App Default Credentials\n    (ADC)](https:\u002F\u002Fdocs.cloud.google.com\u002Fdocs\u002Fauthentication\u002Fapplication-default-credentials.md.txt)\n    (`gcloud auth application-default login`)**: This is different from CLI\n    auth. It creates a local JSON file that Google Cloud **Client Libraries**\n    (Python, Java, etc.) use to act as \"you\" when you run code on your laptop.\n*   **[Service Account\n    Impersonation](https:\u002F\u002Fdocs.cloud.google.com\u002Fdocs\u002Fauthentication\u002Fuse-service-account-impersonation.md.txt)**:\n    For security reasons, developers should avoid downloading Service Account\n    keys entirely. Instead, they should authenticate as humans (`gcloud auth\n    login`) and use Service Account Impersonation to run CLI commands or\n    generate short-lived credentials. This is a critical best practice for local\n    development and troubleshooting.\n\n### For End-Users and Customers\n\nUsed when a human (who is not a developer) needs to access a web application\nyou've deployed on Google Cloud. Note: These are distinct from workforce\nidentities.\n\n*   **[Identity-Aware Proxy (IAP)](https:\u002F\u002Fdocs.cloud.google.com\u002Fiap\u002Fdocs.md.txt)**:\n    Acts as a central authorization layer for web applications. It intercepts\n    web requests and verifies the user's identity (via Google Workspace, Cloud\n    Identity, or external providers) before letting them reach the application.\n    It's often used to protect internal apps without a VPN, or secure customer\n    portals.\n*   **[Identity\n    Platform](https:\u002F\u002Fdocs.cloud.google.com\u002Fidentity-platform\u002Fdocs.md.txt)**: A\n    Customer Identity and Access Management (CIAM) solution for adding consumer\n    sign-in (email\u002Fpassword, phone, social) directly into the code of your\n    custom-built applications.\n\n---\n\n## Service-to-Service Authentication\n\nWhen code runs in production, it should use a **Service Account** rather than a\nhuman user account.\n\n### Service Accounts and Service Agents\n\n*   **[Service\n    Account](https:\u002F\u002Fdocs.cloud.google.com\u002Fiam\u002Fdocs\u002Fservice-account-overview.md.txt)**:\n    A special identity intended for non-human users. It's like a \"robot\n    identity\" with its own email address.\n*   **[Service Agent](https:\u002F\u002Fdocs.cloud.google.com\u002Fiam\u002Fdocs\u002Fservice-agents.md.txt)**:\n    A service account managed by Google that allows a service (like Pub\u002FSub) to\n    access your resources on your behalf.\n\n### Best Practice: Attaching Service Accounts\n\nInstead of using **Service Account Keys** (dangerous JSON files), you should\n**attach** a custom service account to the Google Cloud resource. The resource's\nenvironment then provides a **Token** (a short-lived digital object) via a local\nmetadata server.\n\n*   **[Compute\n    Engine](https:\u002F\u002Fdocs.cloud.google.com\u002Fcompute\u002Fdocs\u002Faccess\u002Fcreate-enable-service-accounts-for-instances.md.txt)**:\n    Assign a service account during VM creation.\n*   **[Cloud\n    Run](https:\u002F\u002Fdocs.cloud.google.com\u002Frun\u002Fdocs\u002Fsecuring\u002Fservice-identity.md.txt)**:\n    Assign a service account in the service configuration.\n\n### Special Cases & Advanced Topics\n\n#### Kubernetes Engine (GKE)\n\nUse **[Workload Identity Federation for\nGKE](https:\u002F\u002Fdocs.cloud.google.com\u002Fkubernetes-engine\u002Fdocs\u002Fhow-to\u002Fworkload-identity.md.txt)**\nto map Kubernetes identities to IAM principal identifiers. This grants specific\nKubernetes workloads access to specific Google Cloud APIs. [Learn more\nhere.](https:\u002F\u002Fdocs.cloud.google.com\u002Fkubernetes-engine\u002Fdocs\u002Fhow-to\u002Fworkload-identity.md.txt)\n\n#### External Workloads ([Workload Identity Federation](https:\u002F\u002Fdocs.cloud.google.com\u002Fiam\u002Fdocs\u002Fworkload-identity-federation.md.txt))\n\nFor code running **outside** Google Cloud (e.g., AWS, Azure, or on-prem), do not\nuse keys. Instead, use Workload Identity Federation to exchange an external\ntoken (like an AWS IAM role) for a short-lived Google Cloud access token.\n\n#### [API Keys](https:\u002F\u002Fdocs.cloud.google.com\u002Fdocs\u002Fauthentication\u002Fapi-keys.md.txt)\n\nAPI keys are encrypted strings used for public data (e.g., Google Maps) or\nsimplified access like **[Vertex AI Express\nMode](https:\u002F\u002Fdocs.cloud.google.com\u002Fvertex-ai\u002Fgenerative-ai\u002Fdocs\u002Fstart\u002Fexpress-mode\u002Foverview.md.txt)**,\nwhich allows fast testing of Gemini models without complex setup. Both humans\nand services (e.g., Cloud Run-based AI agent) can use API keys, for the services\nthat support it.\n\nNote: API keys should be\n[restricted](https:\u002F\u002Fdocs.cloud.google.com\u002Fapi-keys\u002Fdocs\u002Fadd-restrictions-api-keys.md.txt)\nto specific APIs and projects to minimize security risks. Store API keys in a\nsecrets manager like [Secret\nManager](https:\u002F\u002Fdocs.cloud.google.com\u002Fsecret-manager\u002Fdocs.md.txt) to prevent\naccidental exposure.\n\n#### OAuth 2.0 Access Scopes\n\nWhile IAM is the modern way to handle authorization, legacy Compute Engine VMs\nand GKE node pools still rely on **Access Scopes** alongside IAM. If a VM's\nscope is restricted, the attached service account will fail to make API calls\neven if it has the correct IAM permissions. Check this first if attached service\naccounts are failing unexpectedly.\n\n#### Short-Lived Credentials\n\nThe underlying mechanism for impersonation and secure service-to-service\ncommunication is the **IAM Service Account Credentials API**. This API generates\nshort-lived access tokens, OpenID Connect (OIDC) ID tokens, or self-signed JSON\nWeb Tokens (JWTs) dynamically, removing the need for static credentials.\n\n---\n\n## Authorization\n\nAfter Authentication, Google Cloud uses **[Identity and Access Management\n(IAM)](https:\u002F\u002Fdocs.cloud.google.com\u002Fiam\u002Fdocs\u002Foverview.md.txt)** to determine what the\nauthenticated principal can do.\n\n*   **Allow Policy**: A record that binds a **Principal** to a **Role** on a\n    **Resource**.\n*   **[Predefined\n    Roles](https:\u002F\u002Fdocs.cloud.google.com\u002Fiam\u002Fdocs\u002Froles-permissions)**:\n    Prebuilt roles like `roles\u002Fstorage.objectViewer` or\n    `roles\u002Fbigquery.dataEditor`. **Always try to use these first.**\n*   **[Custom\n    Roles](https:\u002F\u002Fdocs.cloud.google.com\u002Fiam\u002Fdocs\u002Fcreating-custom-roles.md.txt)**:\n    User-defined collections of specific permissions if predefined roles are too\n    broad.\n\n---\n\n## Examples\n\n### Human-to-Service (Local Python Development)\n\n1.  **Authn**: Run `gcloud auth application-default login` to create local\n    credentials (ADC).\n2.  **Authz**: Grant your email the `roles\u002Fstorage.objectViewer` role on a\n    bucket.\n3.  **Code**: Use the Python `storage.Client()`. It automatically finds your\n    local credentials via ADC. *Note: ADC searches in a specific order—first\n    checking the `GOOGLE_APPLICATION_CREDENTIALS` environment variable, then the\n    local gcloud JSON file, and finally the attached service account metadata\n    server.*\n\n### Service-to-Service (Cloud Run to Cloud SQL)\n\n1.  **Authn**: Attach a custom Service Account to your Cloud Run service.\n2.  **Authz**: Grant that Service Account the `roles\u002Fcloudsql.client` role on\n    the project.\n3.  **Code**: The Cloud Run environment provides the token automatically to the\n    connection driver.\n\n### Calling a Custom Application ([OIDC](https:\u002F\u002Fdocs.cloud.google.com\u002Fdocs\u002Fauthentication\u002Fget-id-token.md.txt))\n\nWhen calling a private Cloud Run service from another service, the caller\ngenerates a Google-signed **OpenID Connect (OIDC) ID Token** and passes it in\nthe `Authorization: Bearer \u003CTOKEN>` header.\n\n---\n\n## Validation Checklist\n\n-   [ ] Is the user running code locally? Suggest `gcloud auth\n    application-default login` or **Service Account Impersonation**.\n-   [ ] Is the user attempting to use Service Account keys locally? Strongly\n    discourage this and recommend impersonation.\n-   [ ] Is the user running in production? Recommend attaching a custom,\n    least-privilege service account, NOT using keys.\n-   [ ] Is the user relying on the Compute Engine Default Service Account?\n    Recommend creating a custom service account instead.\n-   [ ] Is the user running on another cloud? Recommend Workload Identity\n    Federation.\n-   [ ] Is the user calling a custom app? Recommend OIDC ID Tokens.\n-   [ ] Has the user restricted their API Keys? Check for appropriate [API Key\n    Restrictions](https:\u002F\u002Fdocs.cloud.google.com\u002Fdocs\u002Fauthentication\u002Fapi-keys.md.txt).\n\n## References\n\n-   [Authentication Overview](https:\u002F\u002Fdocs.cloud.google.com\u002Fdocs\u002Fauthentication.md.txt)\n-   [User Identities](https:\u002F\u002Fdocs.cloud.google.com\u002Fiam\u002Fdocs\u002Fuser-identities.md.txt)\n-   [Application Default Credentials](https:\u002F\u002Fdocs.cloud.google.com\u002Fdocs\u002Fauthentication\u002Fprovide-credentials-adc.md.txt)\n-   [Service Account Best Practices](https:\u002F\u002Fdocs.cloud.google.com\u002Fiam\u002Fdocs\u002Fbest-practices-service-accounts.md.txt)\n\n\n","# Authenticating and Authorizing to Google Cloud (IAM)\n\n[Authentication](https:\u002F\u002Fdocs.cloud.google.com\u002Fdocs\u002Fauthentication.md.txt) is the\nprocess of proving **who you are**. In Google Cloud, you represent a\n**Principal** (an identity like a user or a service). This is the first step\nbefore [Authorization](https:\u002F\u002Fdocs.cloud.google.com\u002Fiam\u002Fdocs\u002Foverview.md.txt)\n(determining **what you can do**).\n\n## Attribution\n\n**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you\nMUST read [Usage Attribution](references\u002Fattribution.md). For commands executed\ndirectly in the terminal (never in generated scripts, Terraform, or user code),\nprefix `gcloud` with\n`CLOUDSDK_METRICS_REQUEST_ATTRIBUTION=\"agent-skills\u002F1.0 (skill:google-cloud-recipe-auth)\"`\nand append `agent-skills\u002F1.0 (skill:google-cloud-recipe-auth)` to `User-Agent` headers.\n\n## Authentication\n\n### Clarifying Questions for the Agent\n\nBefore providing a specific solution, clarify the following with the user:\n\n1.  **Who or what is authenticating?** (A human developer, a local script, or an\n    application running in production?)\n2.  **Where is the code running?** (Local laptop, [Compute\n    Engine](https:\u002F\u002Fdocs.cloud.google.com\u002Fcompute\u002Fdocs.md.txt),\n    [GKE](https:\u002F\u002Fdocs.cloud.google.com\u002Fkubernetes-engine\u002Fdocs.md.txt), [Cloud\n    Run](https:\u002F\u002Fdocs.cloud.google.com\u002Frun\u002Fdocs.md.txt), or another cloud like\n    AWS\u002FAzure?)\n3.  **What is the target?** (A Google Cloud API like Storage\u002FBigQuery, or a\n    custom application you built?)\n4.  **Are you using a high-level client library?** (e.g., Python, Go, Node.js\n    libraries usually handle ADC automatically.)\n\n---\n\n## Human Authentication\n\nFor users to access Google Cloud, they need an identity that Google Cloud can\nrecognize.\n\n### Types of User Identities\n\nGoogle Cloud supports several ways to configure identities for your internal\nworkforce (developers, administrators, employees):\n\n*   **[Google-Managed\n    Accounts](https:\u002F\u002Fdocs.cloud.google.com\u002Fiam\u002Fdocs\u002Fuser-identities.md.txt)**:\n    You can use Cloud Identity or Google Workspace to create managed user\n    accounts. These are called managed accounts because your organization\n    controls their lifecycle and configuration.\n*   **[Federation using Cloud Identity or Google\n    Workspace](https:\u002F\u002Fdocs.cloud.google.com\u002Fiam\u002Fdocs\u002Fuser-identities.md.txt)**:\n    You can federate identities to allow users to use their existing identity\n    and credentials to sign in to Google services. Users authenticate against an\n    external identity provider (IdP), but you must keep accounts synchronized\n    into Google Cloud using tools like Google Cloud Directory Sync (GCDS) or an\n    external authoritative source like Active Directory or Microsoft Entra ID.\n*   **[Workforce Identity\n    Federation](https:\u002F\u002Fdocs.cloud.google.com\u002Fiam\u002Fdocs\u002Fuser-identities.md.txt)**:\n    This lets you use an external IdP to authenticate and authorize a workforce\n    using IAM directly. Unlike standard federation, you do not need to\n    synchronize user identities from your existing IdP to Google Cloud\n    identities. It supports syncless, attribute-based single sign-on.\n\n### Methods of Access for Developers and Administrators\n\nUsed for interacting with Google Cloud resources and APIs during development and\nmanagement.\n\n*   **[Google Cloud Console](https:\u002F\u002Fconsole.cloud.google.com\u002F)**: The primary\n    web interface. You authenticate using your Google Account (Gmail or [Google\n    Workspace](https:\u002F\u002Fworkspace.google.com\u002F)).\n*   **[gcloud CLI](https:\u002F\u002Fdocs.cloud.google.com\u002Fsdk\u002Fdocs\u002Finstall-sdk.md.txt) (`gcloud\n    auth login`)**: Used to authenticate the CLI itself so you can run\n    management commands (e.g., `gcloud compute instances list`). It uses a\n    **Credential** (like an OAuth 2.0 refresh token) stored locally.\n*   **Local Development with [App Default Credentials\n    (ADC)](https:\u002F\u002Fdocs.cloud.google.com\u002Fdocs\u002Fauthentication\u002Fapplication-default-credentials.md.txt)\n    (`gcloud auth application-default login`)**: This is different from CLI\n    auth. It creates a local JSON file that Google Cloud **Client Libraries**\n    (Python, Java, etc.) use to act as \"you\" when you run code on your laptop.\n*   **[Service Account\n    Impersonation](https:\u002F\u002Fdocs.cloud.google.com\u002Fdocs\u002Fauthentication\u002Fuse-service-account-impersonation.md.txt)**:\n    For security reasons, developers should avoid downloading Service Account\n    keys entirely. Instead, they should authenticate as humans (`gcloud auth\n    login`) and use Service Account Impersonation to run CLI commands or\n    generate short-lived credentials. This is a critical best practice for local\n    development and troubleshooting.\n\n### For End-Users and Customers\n\nUsed when a human (who is not a developer) needs to access a web application\nyou've deployed on Google Cloud. Note: These are distinct from workforce\nidentities.\n\n*   **[Identity-Aware Proxy (IAP)](https:\u002F\u002Fdocs.cloud.google.com\u002Fiap\u002Fdocs.md.txt)**:\n    Acts as a central authorization layer for web applications. It intercepts\n    web requests and verifies the user's identity (via Google Workspace, Cloud\n    Identity, or external providers) before letting them reach the application.\n    It's often used to protect internal apps without a VPN, or secure customer\n    portals.\n*   **[Identity\n    Platform](https:\u002F\u002Fdocs.cloud.google.com\u002Fidentity-platform\u002Fdocs.md.txt)**: A\n    Customer Identity and Access Management (CIAM) solution for adding consumer\n    sign-in (email\u002Fpassword, phone, social) directly into the code of your\n    custom-built applications.\n\n---\n\n## Service-to-Service Authentication\n\nWhen code runs in production, it should use a **Service Account** rather than a\nhuman user account.\n\n### Service Accounts and Service Agents\n\n*   **[Service\n    Account](https:\u002F\u002Fdocs.cloud.google.com\u002Fiam\u002Fdocs\u002Fservice-account-overview.md.txt)**:\n    A special identity intended for non-human users. It's like a \"robot\n    identity\" with its own email address.\n*   **[Service Agent](https:\u002F\u002Fdocs.cloud.google.com\u002Fiam\u002Fdocs\u002Fservice-agents.md.txt)**:\n    A service account managed by Google that allows a service (like Pub\u002FSub) to\n    access your resources on your behalf.\n\n### Best Practice: Attaching Service Accounts\n\nInstead of using **Service Account Keys** (dangerous JSON files), you should\n**attach** a custom service account to the Google Cloud resource. The resource's\nenvironment then provides a **Token** (a short-lived digital object) via a local\nmetadata server.\n\n*   **[Compute\n    Engine](https:\u002F\u002Fdocs.cloud.google.com\u002Fcompute\u002Fdocs\u002Faccess\u002Fcreate-enable-service-accounts-for-instances.md.txt)**:\n    Assign a service account during VM creation.\n*   **[Cloud\n    Run](https:\u002F\u002Fdocs.cloud.google.com\u002Frun\u002Fdocs\u002Fsecuring\u002Fservice-identity.md.txt)**:\n    Assign a service account in the service configuration.\n\n### Special Cases & Advanced Topics\n\n#### Kubernetes Engine (GKE)\n\nUse **[Workload Identity Federation for\nGKE](https:\u002F\u002Fdocs.cloud.google.com\u002Fkubernetes-engine\u002Fdocs\u002Fhow-to\u002Fworkload-identity.md.txt)**\nto map Kubernetes identities to IAM principal identifiers. This grants specific\nKubernetes workloads access to specific Google Cloud APIs. [Learn more\nhere.](https:\u002F\u002Fdocs.cloud.google.com\u002Fkubernetes-engine\u002Fdocs\u002Fhow-to\u002Fworkload-identity.md.txt)\n\n#### External Workloads ([Workload Identity Federation](https:\u002F\u002Fdocs.cloud.google.com\u002Fiam\u002Fdocs\u002Fworkload-identity-federation.md.txt))\n\nFor code running **outside** Google Cloud (e.g., AWS, Azure, or on-prem), do not\nuse keys. Instead, use Workload Identity Federation to exchange an external\ntoken (like an AWS IAM role) for a short-lived Google Cloud access token.\n\n#### [API Keys](https:\u002F\u002Fdocs.cloud.google.com\u002Fdocs\u002Fauthentication\u002Fapi-keys.md.txt)\n\nAPI keys are encrypted strings used for public data (e.g., Google Maps) or\nsimplified access like **[Vertex AI Express\nMode](https:\u002F\u002Fdocs.cloud.google.com\u002Fvertex-ai\u002Fgenerative-ai\u002Fdocs\u002Fstart\u002Fexpress-mode\u002Foverview.md.txt)**,\nwhich allows fast testing of Gemini models without complex setup. Both humans\nand services (e.g., Cloud Run-based AI agent) can use API keys, for the services\nthat support it.\n\nNote: API keys should be\n[restricted](https:\u002F\u002Fdocs.cloud.google.com\u002Fapi-keys\u002Fdocs\u002Fadd-restrictions-api-keys.md.txt)\nto specific APIs and projects to minimize security risks. Store API keys in a\nsecrets manager like [Secret\nManager](https:\u002F\u002Fdocs.cloud.google.com\u002Fsecret-manager\u002Fdocs.md.txt) to prevent\naccidental exposure.\n\n#### OAuth 2.0 Access Scopes\n\nWhile IAM is the modern way to handle authorization, legacy Compute Engine VMs\nand GKE node pools still rely on **Access Scopes** alongside IAM. If a VM's\nscope is restricted, the attached service account will fail to make API calls\neven if it has the correct IAM permissions. Check this first if attached service\naccounts are failing unexpectedly.\n\n#### Short-Lived Credentials\n\nThe underlying mechanism for impersonation and secure service-to-service\ncommunication is the **IAM Service Account Credentials API**. This API generates\nshort-lived access tokens, OpenID Connect (OIDC) ID tokens, or self-signed JSON\nWeb Tokens (JWTs) dynamically, removing the need for static credentials.\n\n---\n\n## Authorization\n\nAfter Authentication, Google Cloud uses **[Identity and Access Management\n(IAM)](https:\u002F\u002Fdocs.cloud.google.com\u002Fiam\u002Fdocs\u002Foverview.md.txt)** to determine what the\nauthenticated principal can do.\n\n*   **Allow Policy**: A record that binds a **Principal** to a **Role** on a\n    **Resource**.\n*   **[Predefined\n    Roles](https:\u002F\u002Fdocs.cloud.google.com\u002Fiam\u002Fdocs\u002Froles-permissions)**:\n    Prebuilt roles like `roles\u002Fstorage.objectViewer` or\n    `roles\u002Fbigquery.dataEditor`. **Always try to use these first.**\n*   **[Custom\n    Roles](https:\u002F\u002Fdocs.cloud.google.com\u002Fiam\u002Fdocs\u002Fcreating-custom-roles.md.txt)**:\n    User-defined collections of specific permissions if predefined roles are too\n    broad.\n\n---\n\n## Examples\n\n### Human-to-Service (Local Python Development)\n\n1.  **Authn**: Run `gcloud auth application-default login` to create local\n    credentials (ADC).\n2.  **Authz**: Grant your email the `roles\u002Fstorage.objectViewer` role on a\n    bucket.\n3.  **Code**: Use the Python `storage.Client()`. It automatically finds your\n    local credentials via ADC. *Note: ADC searches in a specific order—first\n    checking the `GOOGLE_APPLICATION_CREDENTIALS` environment variable, then the\n    local gcloud JSON file, and finally the attached service account metadata\n    server.*\n\n### Service-to-Service (Cloud Run to Cloud SQL)\n\n1.  **Authn**: Attach a custom Service Account to your Cloud Run service.\n2.  **Authz**: Grant that Service Account the `roles\u002Fcloudsql.client` role on\n    the project.\n3.  **Code**: The Cloud Run environment provides the token automatically to the\n    connection driver.\n\n### Calling a Custom Application ([OIDC](https:\u002F\u002Fdocs.cloud.google.com\u002Fdocs\u002Fauthentication\u002Fget-id-token.md.txt))\n\nWhen calling a private Cloud Run service from another service, the caller\ngenerates a Google-signed **OpenID Connect (OIDC) ID Token** and passes it in\nthe `Authorization: Bearer \u003CTOKEN>` header.\n\n---\n\n## Validation Checklist\n\n-   [ ] Is the user running code locally? Suggest `gcloud auth\n    application-default login` or **Service Account Impersonation**.\n-   [ ] Is the user attempting to use Service Account keys locally? Strongly\n    discourage this and recommend impersonation.\n-   [ ] Is the user running in production? Recommend attaching a custom,\n    least-privilege service account, NOT using keys.\n-   [ ] Is the user relying on the Compute Engine Default Service Account?\n    Recommend creating a custom service account instead.\n-   [ ] Is the user running on another cloud? Recommend Workload Identity\n    Federation.\n-   [ ] Is the user calling a custom app? Recommend OIDC ID Tokens.\n-   [ ] Has the user restricted their API Keys? Check for appropriate [API Key\n    Restrictions](https:\u002F\u002Fdocs.cloud.google.com\u002Fdocs\u002Fauthentication\u002Fapi-keys.md.txt).\n\n## References\n\n-   [Authentication Overview](https:\u002F\u002Fdocs.cloud.google.com\u002Fdocs\u002Fauthentication.md.txt)\n-   [User Identities](https:\u002F\u002Fdocs.cloud.google.com\u002Fiam\u002Fdocs\u002Fuser-identities.md.txt)\n-   [Application Default Credentials](https:\u002F\u002Fdocs.cloud.google.com\u002Fdocs\u002Fauthentication\u002Fprovide-credentials-adc.md.txt)\n-   [Service Account Best Practices](https:\u002F\u002Fdocs.cloud.google.com\u002Fiam\u002Fdocs\u002Fbest-practices-service-accounts.md.txt)\n\n\n",{"name":5,"metadata":43,"description":7},{"version":44,"category":45},"1.0.2","GettingStarted","main","bb9b3f464aae37af360d079c1d863524955b0363","skills\u002Fcloud\u002Fgoogle-cloud-recipe-auth",2005,"https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fskills","https:\u002F\u002Fgithub.com\u002Fgoogle","https:\u002F\u002Fopensource.google\u002F","Google ❤️ Open Source","2026-11-14 01:51:35",{"source":8,"skillName":5,"commands":56,"prompt":66,"zipAvailable":67},[57,60,63],{"tool":58,"command":59},"npx","npx skills add google\u002Fskills --skill google-cloud-recipe-auth",{"tool":61,"command":62},"bunx","bunx skills add google\u002Fskills --skill google-cloud-recipe-auth",{"tool":64,"command":65},"pnpm","pnpm dlx skills add google\u002Fskills --skill google-cloud-recipe-auth","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fcloud\u002Fgoogle-cloud-recipe-auth\u002FSKILL.md",true,[69],{"path":70,"resourceType":71,"resourceTypeDesc":72,"sizeBytes":73,"sourceHtmlUrl":74},"references\u002Fattribution.md","REFERENCE","参考文档",1912,"https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fcloud\u002Fgoogle-cloud-recipe-auth\u002Freferences\u002Fattribution.md",[76,110,142,171,198,223],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":90,"publishedAt":38},"01M6998S2EZKD3GEJ7F943RZTE","sign-in-with-google-web","Implement, configure, and secure Sign In With Google (SiwG) using Google Identity Services (GIS \u002F `https:\u002F\u002Faccounts.google.com\u002Fgsi\u002Fclient`) across web architectures. Use when creating Google sign-in buttons, implementing Google One Tap with FedCM, integrating GIS in React\u002FNext.js\u002FAngular\u002FHTML, verifying ID tokens on backend runtimes (Python\u002FNode.js\u002FGo\u002FJava), enforcing Google Workspace domain restrictions (`hd`), securing client-side ID tokens via WebCrypto nonces or encrypted IndexedDB, embedding in cross-origin iframes via the Intermediate Iframe API (`https:\u002F\u002Faccounts.google.com\u002Fgsi\u002Fintermediate`), configuring Content Security Policy (CSP), COOP, and Permissions Policy (`identity-credentials-get`) headers, or handling sign-out and revocation. Don't use for legacy Google Sign-In (`gapi.auth2`), Google Cloud IAM service accounts, or Android\u002FiOS native Credential Manager.","https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fidentity\u002Fsign-in-with-google-web\u002FSKILL.md",[82,87],{"categoryNo":83,"categoryName":84,"taxonomyType":85,"taxonomyTypeDesc":86},"01JBSEEDCAT000000000000009","前端开发","SCENARIO","使用场景",{"categoryNo":88,"categoryName":89,"taxonomyType":85,"taxonomyTypeDesc":86},"01JBSEEDCAT000000000000010","后端与接口",[9,91,92,93,94,95,96,97,98,20,99,100,101,102,103,33,104,105,36,106,37,107,108,109],"sign in with google web","sign","with","web","android","go","security","google workspace","implement","policy","python","implementing","react","permissions","buttons","manager","architectures","domain","runtimes",{"skillNo":111,"name":112,"nameZh":6,"description":113,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":114,"categories":115,"keywords":125,"publishedAt":38},"01M6998PHPDCAD684VW5WRG83D","dpop-adoption","Implement and debug OAuth 2.0 DPoP (RFC 9449) refresh token sender-constraining for WebCrypto, Node.js ES6, and browser runtimes integrating with Google's OAuth platform. Use when configuring non-extractable asymmetric key pairs (P-256), generating DPoP Proof JWTs for authorization code exchange and token refresh, or handling 400 use_dpop_nonce challenge retry loops at oauth2.googleapis.com\u002Ftoken. Don't use for unconstrained OAuth 2.0 flows (where refresh tokens are not bound to a client key pair), or for Google Cloud IAM \u002F service account authentication.","https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fidentity\u002Fdpop-adoption\u002FSKILL.md",[116,117,120],{"categoryNo":88,"categoryName":89,"taxonomyType":85,"taxonomyTypeDesc":86},{"categoryNo":118,"categoryName":119,"taxonomyType":85,"taxonomyTypeDesc":86},"01JBSEEDCAT000000000000023","Skill与智能体开发",{"categoryNo":121,"categoryName":122,"taxonomyType":123,"taxonomyTypeDesc":124},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[126,127,9,20,128,129,130,131,132,133,33,134,135,136,137,138,139,37,109,140,141],"dpop adoption","adoption","es6","retry","authentication","flows","challenge","code","browser","loops","at","node","token","pair","platform","when",{"skillNo":143,"name":144,"nameZh":6,"description":145,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":146,"categories":147,"keywords":154,"publishedAt":38},"01M6998M72TC73EEAQH4XC7EXW","retrieving-developer-knowledge","Searches, retrieves, and synthesizes official Google developer documentation across Google Cloud, AI\u002FGemini, Android, Chrome, Web, Flutter, Go, Firebase, and other Google developer platforms. Integrates with the Developer Knowledge MCP server (search_documents, get_documents, answer_query) or the Developer Knowledge REST API fallback. Use when searching for gcloud CLI commands, API syntax, IAM permissions, official documentation, architectural comparisons, or product choice overviews. Don't use for local filesystem lookups or non-Google documentation.","https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fdevelopers\u002Fretrieving-developer-knowledge\u002FSKILL.md",[148,149,152,153],{"categoryNo":88,"categoryName":89,"taxonomyType":85,"taxonomyTypeDesc":86},{"categoryNo":150,"categoryName":151,"taxonomyType":85,"taxonomyTypeDesc":86},"01JBSEEDCAT000000000000021","资料检索与研究",{"categoryNo":118,"categoryName":119,"taxonomyType":85,"taxonomyTypeDesc":86},{"categoryNo":121,"categoryName":122,"taxonomyType":123,"taxonomyTypeDesc":124},[155,156,157,158,20,159,160,161,162,163,164,165,166,141,167,168,169,33,170,104],"retrieving developer knowledge","knowledge","developer","MCP","mcp server","official","developer documentation","get","search","local","choice","documents","query","api","across","documentation",{"skillNo":172,"name":173,"nameZh":6,"description":174,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":175,"categories":176,"keywords":177,"publishedAt":38},"01M6998J2CZEXS9BES9S3WWFKC","migrate-to-rust","Clones, analyzes, plans, and migrates legacy codebases (C++, Fortran, Java, Python, C, Shell) from a GitHub URL or local directory to a modern, high-performance, deterministic, 100% Safe Rust architecture, tracking live telemetry across every task bucket, test failure\u002Ffix cycle, and Profile-Guided Optimization (PGO) stage, and producing a first-person AI storytelling report and interactive HTML infographic. Use when migrating a GitHub repository or local codebase to Rust, porting legacy C++, Fortran, Python, or Java workloads to memory-safe Rust, designing Struct-of-Arrays (SoA) or SIMD Rust architectures, or optimizing Rust ports with LLVM PGO. Don't use for unrelated non-Rust refactoring or single-line syntax questions.","https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fdevelopers\u002Fmigrate-to-rust\u002FSKILL.md",[],[178,179,180,181,182,183,184,185,101,186,187,188,189,190,191,164,192,193,194,141,195,196,169,197],"migrate to rust","rust","migrate","github","memory","performance","directory","safe","ports","llvm","soa","cycle","porting","fix","arrays","infographic","high-performance","URL","architecture","unrelated",{"skillNo":199,"name":200,"nameZh":6,"description":201,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":202,"categories":203,"keywords":207,"publishedAt":38},"01M6998GCC3K29WZ82KXMB9E02","finding-google-skills","Google platform decision and setup guidance, loaded on demand from Google's skill catalog. Use when a developer is choosing or setting up part of their stack, such as where to run a service, a database, storage, messaging, authentication, analytics, ads, or AI model serving, and a Google product is a reasonable candidate - whether or not a vendor is named - or when a request names a Google product or API. Brings in the matching Google skill so the answer can weigh Google options, their trade-offs, and when they are not the right fit. Skip when the stack is already settled on another provider and no Google product is named, or the task involves no platform choice.","https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fdevelopers\u002Ffinding-google-skills\u002FSKILL.md",[204,205,206],{"categoryNo":88,"categoryName":89,"taxonomyType":85,"taxonomyTypeDesc":86},{"categoryNo":118,"categoryName":119,"taxonomyType":85,"taxonomyTypeDesc":86},{"categoryNo":121,"categoryName":122,"taxonomyType":123,"taxonomyTypeDesc":124},[9,208,209,210,211,140,212,213,214,215,216,130,217,218,219,165,220,221,141,222,168],"finding google skills","storage","as","messaging","model","trade-offs","provider","answer","fit","catalog","up","decision","use","database","candidate",{"skillNo":224,"name":225,"nameZh":6,"description":226,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":227,"categories":228,"keywords":231,"publishedAt":38},"01M6998DWNHTH0BS6W1CY8ZXMP","workload-manager-basics","Use this skill to manage Google Cloud Workload Manager evaluations, rules, scanned resources, and validation results by using public client libraries and the REST API. Use when you need to inspect workload best-practice rules, create and run evaluations for Google Cloud general best practices, SAP, SQL Server, or custom organizational rules, review violations, export results to BigQuery, or automate Workload Manager through client libraries because no service-specific public CLI or MCP server is available. Don't use for general Google Compute Engine instance management, VPC configuration, or standard IAM auditing.","https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fcloud\u002Fworkload-manager-basics\u002FSKILL.md",[229,230],{"categoryNo":88,"categoryName":89,"taxonomyType":85,"taxonomyTypeDesc":86},{"categoryNo":118,"categoryName":119,"taxonomyType":85,"taxonomyTypeDesc":86},[232,233,106,234,9,158,235,20,159,236,237,238,239,141,240,168,33,241,242,243,244],"workload manager basics","workload","basics","cli","review","vpc","resources","inspect","you","create","libraries","server","run"]