에이전트가 자체 권한을 사용하여 ServiceNow 또는 Salesforce와 같은 외부 도구를 인증하도록 하려면 Agent Identity 인증 관리자에서 2-legged OAuth (클라이언트 사용자 인증 정보) 인증 제공업체를 사용하여 아웃바운드 인증을 구성합니다.
2-legged OAuth 인증 제공업체는 사용자 인증 정보와 토큰을 관리하여 인증 흐름을 처리하는 커스텀 코드가 필요하지 않도록 합니다.
2-legged OAuth 워크플로
2-legged OAuth 인증 제공업체는 에이전트의 ID를 사용하며 사용자 동의가 필요하지 않습니다. Google에서 클라이언트 사용자 인증 정보의 저장을 관리합니다. 에이전트 개발 키트 (ADK)를 사용하면 결과 액세스 토큰이 자동으로 검색되어 도구 호출 헤더에 삽입됩니다.
시작하기 전에
- 올바른 인증 방법을 선택했는지 확인합니다.
Agent Identity API를 사용 설정합니다.
API 사용 설정에 필요한 역할
API를 사용 설정하려면
serviceusage.services.enable권한이 필요합니다. 프로젝트를 만든 경우 소유자 역할 (roles/owner)을 통해 이 권한을 이미 보유하고 있을 가능성이 높습니다. 그렇지 않은 경우 서비스 사용량 관리자 역할 (roles/serviceusage.serviceUsageAdmin)을 통해 이 권한을 부여받을 수 있습니다. 역할 부여 방법을 알아보세요.연결하려는 서드 파티 애플리케이션에서 클라이언트 ID 와 클라이언트 보안 비밀번호 를 가져옵니다.
필요한 역할
2-legged Agent Identity 인증 제공업체를 만들고 사용하는 데 필요한 권한을 부여받으려면 관리자에게 프로젝트에 대한 다음 IAM 역할을 부여해 달라고 요청하세요.
-
인증 제공업체를 만들려면 다음 안내를 따르세요.
- Agent Identity 관리자 (
roles/agentidentity.admin) - Agent Identity 편집자 (
roles/agentidentity.editor)
- Agent Identity 관리자 (
-
인증 제공업체를 사용하려면 다음 안내를 따르세요.
- Agent Identity 사용자 (
roles/agentidentity.user) - Agent 기본 액세스 (
roles/aiplatform.agentDefaultAccess) - Agent 컨텍스트 편집자 (
roles/aiplatform.agentContextEditor) - Vertex AI 사용자 (
roles/aiplatform.user) - 서비스 사용량 소비자 (
roles/serviceusage.serviceUsageConsumer)
- Agent Identity 사용자 (
역할 부여에 대한 자세한 내용은 프로젝트, 폴더, 조직에 대한 액세스 관리를 참조하세요.
이러한 사전 정의된 역할에는 2-legged Agent Identity 인증 제공업체를 만들고 사용하는 데 필요한 권한이 포함되어 있습니다. 필요한 정확한 권한을 보려면 필수 권한 섹션을 펼치세요.
필수 권한
2-legged Agent Identity 인증 제공업체를 만들고 사용하려면 다음 권한이 필요합니다.
-
인증 제공업체를 만들려면:
agentidentity.authProviders.create -
인증 제공업체를 사용하려면 다음 안내를 따르세요.
-
agentidentity.authProviders.retrieveCredentials -
aiplatform.endpoints.predict -
aiplatform.sessions.create
-
커스텀 역할이나 다른 사전 정의된 역할을 사용하여 이 권한을 부여받을 수도 있습니다.
2-legged 인증 제공업체 만들기
인증 제공업체를 만들어 서드 파티 애플리케이션의 구성과 사용자 인증 정보를 정의합니다.
2-legged 인증 프로바이더를 만들려면 gcloud CLI를 사용합니다.
-
인증 제공업체를 만듭니다.
gcloud alpha agent-identity authProviders create
AUTH_PROVIDER_NAME\ --location="LOCATION" \ --two-legged-oauth-client-id="CLIENT_ID" \ --two-legged-oauth-client-secret="CLIENT_SECRET" \ --two-legged-oauth-token-endpoint="TOKEN_ENDPOINT" - 인증 제공업체가 목록에 표시되고 상태가
ENABLED인지 확인합니다.gcloud alpha agent-identity authProviders list \ --project="
PROJECT_ID" \ --location="LOCATION" -
에이전트와 로컬 개발 환경이 인증 제공업체에서 사용자 인증 정보를 가져올 수 있도록 액세스 권한을 부여합니다. 배포된 에이전트와 개인 사용자 계정이 인증 제공업체에 액세스하도록 허용하려면 인증 제공업체 리소스에 Agent Identity User(
roles/agentidentity.user) 역할을 부여합니다.-
배포된 에이전트의 SPIFFE ID (Agent Identity)에 대한 액세스 권한을 부여합니다.
gcloud alpha agent-identity authProviders add-iam-policy-binding
AUTH_PROVIDER_NAME\ --project="PROJECT_ID" \ --location="LOCATION" \ --role="roles/agentidentity.user" \ --member="principal://agents.global.org-ORGANIZATION_ID.system.id.goog/resources/aiplatform/projects/PROJECT_NUMBER/locations/LOCATION/reasoningEngines/ENGINE_ID" -
로컬 개발 및 테스트를 위해 개인 사용자 계정에 대한 액세스 권한을 부여합니다 (
adk web).gcloud alpha agent-identity authProviders add-iam-policy-binding
AUTH_PROVIDER_NAME\ --project="PROJECT_ID" \ --location="LOCATION" \ --role="roles/agentidentity.user" \ --member="user:USER_EMAIL"
-
다음을 바꿉니다.
PROJECT_ID: 프로젝트 ID입니다. Google CloudLOCATION: 인증 제공업체와 에이전트가 배포된 위치 (예:us-west1)AUTH_PROVIDER_NAME: 인증 제공업체의 이름 (예:bigquery-mcp-3lo-authprovider)AUTHORIZATION_URL: 인증 서버 URL (예:https://accounts.google.com/o/oauth2/v2/auth)TOKEN_URL: 토큰 서버 URL (예:https://oauth2.googleapis.com/token)CLIENT_ID: 서드 파티 서비스에서 생성한 OAuth 클라이언트 IDCLIENT_SECRET: 서드 파티 서비스에서 생성한 OAuth 클라이언트 보안 비밀번호ORGANIZATION_ID: 조직 ID입니다. Google CloudPROJECT_NUMBER: 프로젝트 번호입니다. Google CloudENGINE_ID: 배포된 추론 엔진 에이전트의 ID입니다.USER_EMAIL: 개인 사용자 계정 이메일 주소입니다.
에이전트 코드에서 인증
에이전트를 인증하려면 ADK를 사용하면 됩니다.
ADK
ADK에서 MCP 도구 모음을 사용하여 에이전트의 코드에서 인증 제공업체를 참조합니다.
from google.adk.agents.llm_agent import LlmAgent from google.adk.auth.credential_manager import CredentialManager from google.adk.integrations.agent_identity import GcpAuthProvider, GcpAuthProviderScheme from google.adk.tools.mcp_tool.mcp_session_manager import StreamableHTTPConnectionParams from google.adk.tools.mcp_tool.mcp_toolset import McpToolset from google.adk.auth.auth_tool import AuthConfig # Register the Google Cloud Auth Provider so the CredentialManager can use it. CredentialManager.register_auth_provider(GcpAuthProvider()) # Create the Google Cloud Auth Provider scheme # Note: If using the legacy V1 API, the resource name uses 'connectors' # instead of 'authProviders': projects/.../connectors/... auth_scheme = GcpAuthProviderScheme( name="projects/PROJECT_ID/locations/LOCATION/authProviders/AUTH_PROVIDER_NAME" ) # Configure an MCP tool with the authentication scheme. toolset = McpToolset( connection_params=StreamableHTTPConnectionParams(url="https://YOUR_MCP_SERVER_URL"), auth_scheme=auth_scheme, ) # Initialize the agent with the authenticated tools. agent = LlmAgent( name="AGENT_NAME", model="gemini-2.5-flash", instruction="AGENT_INSTRUCTIONS", tools=[toolset], )
ADK
ADK에서 인증된 함수 도구를 사용하여 에이전트의 코드에서 인증 제공업체를 참조합니다.
import httpx from google.adk.agents.llm_agent import LlmAgent from google.adk.auth.credential_manager import CredentialManager from google.adk.integrations.agent_identity import GcpAuthProvider from google.adk.integrations.agent_identity import GcpAuthProviderScheme from google.adk.apps import App from google.adk.auth.auth_credential import AuthCredential from google.adk.auth.auth_tool import AuthConfig from google.adk.tools.authenticated_function_tool import AuthenticatedFunctionTool from vertexai import agent_engines # First, register Google Cloud auth provider CredentialManager.register_auth_provider(GcpAuthProvider()) # Create Auth Config # Note: If using the legacy V1 API, the resource name uses 'connectors' # instead of 'authProviders': projects/.../connectors/... spotify_auth_config = AuthConfig( auth_scheme=GcpAuthProviderScheme( name=( "projects/PROJECT_ID/locations/" "LOCATION/authProviders/" "AUTH_PROVIDER_NAME" ) ) ) # Use the Auth Config in Authenticated Function Tool spotify_search_track_tool = AuthenticatedFunctionTool( func=spotify_search_track, auth_config=spotify_auth_config ) # Sample function tool async def spotify_search_track(credential: AuthCredential, query: str) -> str | list: token = None if credential.http and credential.http.credentials: token = credential.http.credentials.token if not token: return "Error: No authentication token available." async with httpx.AsyncClient() as client: response = await client.get( "https://api.spotify.com/v1/search", headers={"Authorization": f"Bearer {token}"}, params={"q": query, "type": "track", "limit": 1}, ) # Add your own logic here agent = LlmAgent( name="AGENT_NAME", model="MODEL_NAME", instruction="AGENT_INSTRUCTIONS", tools=[spotify_search_track_tool], ) app = App( name="APP_NAME", root_agent=agent, ) vertex_app = agent_engines.AdkApp(app_name=app)
ADK
ADK에서 에이전트 레지스트리 MCP 도구 모음을 사용하여 에이전트의 코드에서 인증 제공업체를 참조합니다.
from google.adk.agents.llm_agent import LlmAgent from google.adk.auth.credential_manager import CredentialManager from google.adk.integrations.agent_identity import GcpAuthProvider from google.adk.integrations.agent_identity import GcpAuthProviderScheme from google.adk.tools.mcp_tool.mcp_session_manager import StreamableHTTPConnectionParams from google.adk.tools.mcp_tool.mcp_toolset import McpToolset from google.adk.auth.auth_tool import AuthConfig from google.adk.integrations.agent_registry import AgentRegistry # First, register Google Cloud auth provider CredentialManager.register_auth_provider(GcpAuthProvider()) # Create Google Cloud auth provider scheme # Note: If using the legacy V1 API, the resource name uses 'connectors' # instead of 'authProviders': projects/.../connectors/... auth_scheme = GcpAuthProviderScheme( name=( "projects/PROJECT_ID/locations/" "LOCATION/authProviders/" "AUTH_PROVIDER_NAME" ) ) # Set Agent Registry registry = AgentRegistry(project_id="PROJECT_ID", location="global") toolset = registry.get_mcp_toolset( mcp_server_name=( "projects/PROJECT_ID/locations/" "global/mcpServers/" "agentregistry-00000000-0000-0000-0000-000000000000" ), auth_scheme=auth_scheme, ) # Example MCP tool toolset = McpToolset( connection_params=StreamableHTTPConnectionParams(url="MCP_URL"), auth_scheme=auth_scheme, ) agent = LlmAgent( name="AGENT_NAME", model="MODEL_NAME", instruction="AGENT_INSTRUCTIONS", tools=[toolset], )
로컬 테스트를 위한 종속 항목 설치
가상 환경에서 에이전트를 로컬로 테스트하려면 다음 필수 종속 항목을 설치합니다.
- 가상 환경 만들기 및 활성화
python3 -m venv env source env/bin/activate
- 필요한 패키지를 설치합니다.
pip install google-cloud-aiplatform[agent_engines,adk] google-adk[agent-identity]
에이전트 배포
에이전트를 Google Cloud에 배포할 때는 Agent Identity가 사용 설정되어 있는지 확인합니다.
Gemini Enterprise Agent Platform의
Agent Runtime
에 배포하는 경우 identity_type=AGENT_IDENTITY
플래그를 사용합니다.
import vertexai
from vertexai import types
from vertexai.agent_engines import AdkApp
# Initialize the Vertex AI client with v1beta1 API for Agent Identity support
client = vertexai.Client(
project="PROJECT_ID",
location="LOCATION",
http_options=dict(api_version="v1beta1")
)
# Use the proper wrapper class for your Agent Framework (e.g., AdkApp)
app = AdkApp(agent=agent)
# Deploy the agent with Agent Identity enabled
remote_app = client.agent_engines.create(
agent=app,
config={
"identity_type": types.IdentityType.AGENT_IDENTITY,
"requirements": ["google-cloud-aiplatform[agent_engines,adk]", "google-adk[agent-identity]"],
},
)
다음 단계
- Agent Identity 개요
- 인증 관리자를 사용하여 3-legged OAuth로 인증
- 인증 관리자를 사용하여 API 키로 인증
- Agent Identity 인증 제공업체 관리
- Agent Identity 인증 관리자 문제 해결