인증된 HTTP 요청을 수행하려면 적절한 사용자 인증 정보가 있는 서비스 계정(이메일 주소로 식별됨)에 워크플로를 연결해야 합니다. 워크플로에 Identity and Access Management(IAM) 서비스 계정을 연결하고 리소스에 액세스하는 데 필요한 권한을 부여하는 방법에 대한 자세한 내용은 워크플로에 Google Cloud 리소스에 대한 액세스 권한 부여를 참조하세요.
인증 토큰
기본적으로 HTTP 요청은 보안상의 이유로 ID 또는 액세스 토큰을 포함하지 않습니다. 워크플로 정의에 인증 정보를 명시적으로 추가해야 합니다.
Workflows와 이러한 인증이 필요한 HTTP 대상 간에 인증하기 위해 Workflows는 워크플로에 연결된 서비스 계정의 사용자 인증 정보를 기반으로 승인 헤더의 토큰을 사용하고 HTTPS를 사용하여 토큰을 대상 서비스에 전송합니다. Cloud Run 함수나 Cloud Run과 연결할 때 ID 토큰(OIDC)을 사용합니다. googleapis.com에서 호스팅되는 API에는 액세스 토큰(OAuth 2.0)을 사용합니다.
워크플로 내에서 인증된 요청을 수행하려면 호출 중인 서비스에 따라 다음 중 하나를 수행하세요.
외부 API: Authorization 요청 헤더를 사용하여 서드 파티 API로 인증합니다. 이 문서에서 외부 API에 인증된 요청 수행을 참조하세요.
Google Cloud API — 가능한 경우 워크플로의 서비스 계정을 사용하여 필요한 인증을 자동으로 제공하는 Workflows 커넥터를 사용합니다. 커넥터를 사용할 수 없는 경우 OAuth 2.0과 함께 HTTP 요청을 사용하여 다른 Google Cloud API와 연결합니다. 호스트 이름이 .googleapis.com으로 끝나는 API에는 이 인증 방법이 허용됩니다. 이 문서에서 Google Cloud API에 인증된 요청 수행을 참조하세요.
타사 API를 통합하는 경우 인증을 수행하는 데 필요한 사용자 인증 정보가 있는 Authorization 요청 헤더를 포함합니다. 예를 들어 서비스에 대한 요청의 Authorization: Bearer ID_TOKEN 헤더에 ID 토큰을 포함합니다. 자세한 내용은 API 제공업체의 문서를 참조하세요.
Google Cloud API에 인증된 요청 수행
워크플로의 서비스 계정은 워크플로가 Google Cloud API 인증에 사용할 수 있는 OAuth 2.0 토큰을 생성할 수 있습니다. 이 인증 방법을 사용할 때 워크플로는 연결된 서비스 계정으로 인증됩니다. OAuth 2.0 프로토콜을 사용하여 HTTP 요청을 수행하려면 URL을 지정한 후, 워크플로 정의의 args 섹션에 auth 섹션을 추가합니다. 이 예시에서는 VM을 중지하기 위해 Compute Engine API에 요청이 전송됩니다.
scopes 키는 선택사항이지만 토큰의 OAuth 2.0 범위를 지정하는 데 사용될 수 있습니다. OAUTH_SCOPE를 문자열 또는 문자열 목록으로 바꿉니다. 공백 및 쉼표로 구분된 문자열도 지원됩니다. 기본적으로 값은 https://www.googleapis.com/auth/cloud-platform으로 설정되어 있습니다.
Cloud Run 함수나 Cloud Run에 요청 전송
요청을 Cloud Run 함수나 Cloud Run에 보낼 때 OIDC를 사용하여 인증합니다.
OIDC를 사용하여 HTTP 요청을 수행하려면 URL을 지정한 후 워크플로 정의의 args 섹션에 auth 섹션을 추가합니다. 이 예시에서는 Cloud Run 함수가 호출되도록 요청이 전송됩니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[],[],null,["# Make authenticated requests from a workflow\n\nTo make authenticated HTTP requests, your workflow must be associated with a\nservice account (identified by its email address) that has the appropriate\ncredentials. For more information about attaching an Identity and Access Management (IAM)\nservice account to a workflow, and granting it the permissions required to\naccess resources, see\n[Grant a workflow permission to access Google Cloud resources](/workflows/docs/authentication).\n\nAuthentication tokens\n---------------------\n\nBy default, HTTP requests don't contain identity or access tokens for security\nreasons. You must explicitly add authentication information to your workflow\ndefinition.\n\nTo authenticate between Workflows and an HTTP target that requires such\nauthentication, Workflows uses a token in the authorization\nheader based on the credentials of the service account attached to the workflow,\nand sends the token using HTTPS to the target service. When connecting with\nCloud Run functions or Cloud Run, use an\n[ID token](/docs/authentication/token-types#id) (OIDC). For APIs hosted on\n`googleapis.com`, use an\n[access token](/docs/authentication/token-types#access) (OAuth 2.0).\n\nTo make an authenticated request from within a workflow, do one of the\nfollowing depending on the service you are calling:\n\n- **External APIs** ---Use an `Authorization` request header to authenticate with a\n third-party API. In this document, see\n [Make authenticated requests to external APIs](#authenticate-external-apis).\n\n- **Google Cloud APIs** ---If available, use a Workflows\n [connector](/workflows/docs/connectors), which automatically provides the\n required authentication using the workflow's service account. If you can't\n use a connector, use an HTTP\n request with OAuth 2.0 to connect with other Google Cloud APIs. Any\n API that ends with a hostname of `.googleapis.com` accepts this authentication\n method. In this document, see\n [Make authenticated requests to Google Cloud APIs](#authenticate-apis).\n\n- **Cloud Run functions or Cloud Run** ---Use OIDC to connect\n with Cloud Run or Cloud Run functions. In this document,\n see\n [Make requests to Cloud Run or Cloud Run functions](#auth-requests-run-functions).\n\n- **Private on‑premises, Compute Engine, Google Kubernetes Engine (GKE),\n or other Google Cloud endpoints** ---Use Identity-Aware Proxy (IAP) with OIDC\n to enforce access control policies for your endpoints. For more information,\n see [Invoke private on‑prem, Compute Engine, GKE,\n or other endpoint](/workflows/docs/enable-iap-call-private-endpoints) and\n [learn how to authenticate to an IAP-secured resource from a\n user or service account](/iap/docs/authentication-howto).\n\nMake authenticated requests to external APIs\n--------------------------------------------\n\nIf you're integrating a third-party API, include an `Authorization` request\nheader with the credentials necessary to carry out the authentication. For\nexample, include an ID token in an\n`Authorization: Bearer `\u003cvar translate=\"no\"\u003eID_TOKEN\u003c/var\u003e header in the request to\nthe service. For more information, consult the API provider's documentation.\n\nMake authenticated requests to Google Cloud APIs\n------------------------------------------------\n\n| **Note:** This authentication method is restricted to HTTPS endpoints with a hostname that ends in `.googleapis.com`.\n\nA workflow's service account can generate OAuth 2.0 tokens that the workflow can\nuse to authenticate to any Google Cloud API. When you use this\nauthentication method, the workflow authenticates as its associated service\naccount. To make an HTTP request using the OAuth 2.0 protocol, add an `auth`\nsection to the `args` section of your workflow's definition, after you specify\nthe URL. In this example, a request is sent to the Compute Engine API to stop a\nVM:\n\n\u003cbr /\u003e\n\n### YAML\n\n```yaml\n - step_A:\n call: http.post\n args:\n url: https://compute.googleapis.com/compute/v1/projects/myproject1234/zones/us-central1-b/instances/myvm001/stop\n auth:\n type: OAuth2\n scopes: OAUTH_SCOPE\n \n```\n\n### JSON\n\n```json\n [\n {\n \"step_A\": {\n \"call\": \"http.post\",\n \"args\": {\n \"url\": \"https://compute.googleapis.com/compute/v1/projects/myproject1234/zones/us-central1-b/instances/myvm001/stop\",\n \"auth\": {\n \"type\": \"OAuth2\",\n \"scopes\": \"\u003cvar translate=\"no\"\u003eOAUTH_SCOPE\u003c/var\u003e\"\n }\n }\n }\n }\n ]\n \n```\nThe `scopes` key is optional, but can be used to specify OAuth 2.0 scopes for the token. Replace \u003cvar translate=\"no\"\u003eOAUTH_SCOPE\u003c/var\u003e with a string or list of strings. Space and comma-separated strings are also supported. By default, the value is set to `https://www.googleapis.com/auth/cloud-platform`.\n\n\u003cbr /\u003e\n\nMake requests to Cloud Run functions or Cloud Run\n-------------------------------------------------\n\n| **Note:** This authentication method is restricted to HTTPS endpoints.\n\nWhen making requests to Cloud Run functions or Cloud Run,\nuse OIDC to authenticate.\n\nTo make an HTTP request using OIDC, add an `auth` section to the `args` section\nof your workflow's definition, after you specify the URL. In this example, a\nrequest is sent to invoke a Cloud Run function:\n\n\u003cbr /\u003e\n\n### YAML\n\n```yaml\n - step_A:\n call: http.get\n args:\n url: https://us-central1-project.cloudfunctions.net/functionA\n query:\n firstNumber: 4\n secondNumber: 6\n operation: sum\n auth:\n type: OIDC\n audience: OIDC_AUDIENCE\n \n```\n\n### JSON\n\n```json\n [\n {\n \"step_A\": {\n \"call\": \"http.get\",\n \"args\": {\n \"url\": \"https://us-central1-project.cloudfunctions.net/functionA\",\n \"query\": {\n \"firstNumber\": 4,\n \"secondNumber\": 6,\n \"operation\": \"sum\"\n },\n \"auth\": {\n \"type\": \"OIDC\",\n \"audience\": \"\u003cvar translate=\"no\"\u003eOIDC_AUDIENCE\u003c/var\u003e\"\n }\n }\n }\n }\n ]\n \n```\nThe `audience` key is optional, but can be used to specify the OIDC audience for the token. By default, \u003cvar translate=\"no\"\u003eOIDC_AUDIENCE\u003c/var\u003e is set to the same value as `url`.\n\n\u003cbr /\u003e\n\nNote that it's possible for Workflows to invoke\nCloud Run functions or Cloud Run services that have ingress\nrestricted to internal traffic. With this configuration, your services are\nunreachable from the internet but can be reached from Workflows.\n\nFor more information, see [Invoke Cloud Run functions or Cloud Run](/workflows/docs/calling-run-functions).\n\nWhat's next\n-----------\n\n- [Make an HTTP request](/workflows/docs/http-requests)\n- [Workflows roles and permissions](/workflows/docs/access-control)"]]