구성

Java 클라이언트 라이브러리는 홈 디렉터리 (System.getProperty("user.home") + "/ads.properties" 또는 ~/ads.properties)에서 ads.properties라는 구성 파일을 찾습니다. 다음 메커니즘 중 하나를 사용하여 GoogleAdsClient를 구성할 때 런타임에 이 경로와 파일 이름을 재정의할 수 있습니다.

  • fromPropertiesFile(PATH_TO_CONFIG_FILE)을 호출합니다. 여기서 PATH_TO_CONFIG_FILE은 구성 파일의 File 경로와 파일 이름입니다.
  • 환경 변수 GOOGLE_ADS_CONFIGURATION_FILE_PATH을 구성 파일의 경로와 파일 이름으로 설정한 후 fromPropertiesFile()를 호출합니다.

구성 파일의 형식은 키-값 쌍의 표준 Java Properties 파일입니다. 지원되는 키는 선택한 인증 흐름에 따라 다릅니다.

데스크톱 및 웹 애플리케이션 흐름에 지원되는 키

단일 사용자 또는 멀티 사용자 애플리케이션 흐름을 사용하는 경우 지원되는 키는 다음과 같습니다.

# Credential for accessing Google's OAuth servers.
# Provided by console.cloud.google.com.
api.googleads.clientId=INSERT_CLIENT_ID_HERE

# Credential for accessing Google's OAuth servers.
# Provided by console.cloud.google.com.
api.googleads.clientSecret=INSERT_CLIENT_SECRET_HERE

# Renewable OAuth credential associated with 1 or more Google Ads accounts.
api.googleads.refreshToken=INSERT_REFRESH_TOKEN_HERE

# Required for manager accounts only: Specify the login customer ID used to
# authenticate API calls. This will be the customer ID of the authenticated
# manager account. You can also specify this later in code if your application
# uses multiple manager account + OAuth pairs.
#
# api.googleads.loginCustomerId=INSERT_LOGIN_CUSTOMER_ID_HERE

# Only required if explicitly instructed by the service documentation.
# api.googleads.linkedCustomerId=INSERT_LINKED_CUSTOMER_ID_HERE

# Maximum allowed response payload size, in bytes.
# Customize this to allow response sizes for GoogleAdsService.search and
# GoogleAdsService.searchStream API calls to exceed the default limit of 64MB.
# api.googleads.maxInboundMessageBytes=INSERT_MAX_INBOUND_MESSAGE_BYTES_HERE

# Specifies whether to use Application Default Credentials.
api.googleads.useApplicationDefaultCredentials=false

서비스 계정에서 지원되는 키

서비스 계정 흐름을 사용하는 경우 지원되는 키는 다음과 같습니다.

# Path to the service account secrets file in JSON format.
# Provided by console.cloud.google.com.
api.googleads.serviceAccountSecretsPath=INSERT_PATH_TO_JSON_HERE

# Optional: Email address of the user to impersonate when using Google Workspace
# domain-wide delegation. This should be a user who has access to your Google Ads
# account and is in the same Google Workspace domain as the service account.
# api.googleads.serviceAccountUser=INSERT_USER_EMAIL_ADDRESS_HERE

# Required for manager accounts only: Specify the login customer ID used to
# authenticate API calls. This will be the customer ID of the authenticated
# manager account. You can also specify this later in code if your application
# uses multiple manager account + OAuth pairs.
#
# api.googleads.loginCustomerId=INSERT_LOGIN_CUSTOMER_ID_HERE

환경 변수 사용

이 라이브러리는 모든 표준 Google Ads API 클라이언트 라이브러리 환경 변수를 지원합니다. 다음 표에는 각 구성 파일 속성에 해당하는 환경 변수가 나와 있습니다.

구성 파일 속성 환경 변수
api.googleads.clientId GOOGLE_ADS_CLIENT_ID
api.googleads.clientSecret GOOGLE_ADS_CLIENT_SECRET
api.googleads.refreshToken GOOGLE_ADS_REFRESH_TOKEN
api.googleads.serviceAccountSecretsPath GOOGLE_ADS_JSON_KEY_FILE_PATH
api.googleads.serviceAccountUser GOOGLE_ADS_IMPERSONATED_EMAIL
api.googleads.loginCustomerId GOOGLE_ADS_LOGIN_CUSTOMER_ID
api.googleads.linkedCustomerId GOOGLE_ADS_LINKED_CUSTOMER_ID
api.googleads.maxInboundMessageBytes GOOGLE_ADS_MAX_INBOUND_MESSAGE_BYTES
api.googleads.useApplicationDefaultCredentials GOOGLE_ADS_USE_APPLICATION_DEFAULT_CREDENTIALS
api.googleads.developerToken (v46.0.0 이상에서는 선택사항) GOOGLE_ADS_DEVELOPER_TOKEN

적절한 환경 변수를 설정한 후 빌더에서 fromEnvironment()를 호출하여 GoogleAdsClient를 구성합니다.

GoogleAdsClient googleAdsClient =
    GoogleAdsClient.newBuilder()
        .fromEnvironment()
        .build();

구성 접근 방식 결합

GoogleAdsClient와 빌더는 다양한 구성 전략의 결합을 지원합니다. 예를 들어 환경 변수를 사용하여 인스턴스의 사용자 인증 정보와 기타 속성의 속성 파일을 구성할 수 있습니다.

GoogleAdsClient googleAdsClient =
    GoogleAdsClient.newBuilder()
        .fromEnvironment()
        .fromPropertiesFile()
        .build();

build()를 호출하기 전에 빌더의 다른 구성 메서드를 사용하여 런타임에 추가 변경사항을 적용할 수 있습니다.

개발자 토큰 지원 종료

2026년 9월 9일 개발자 토큰 지원 종료 후에는 API 액세스 수준이 개발자 토큰이 아닌 API 서버의 Google Cloud 프로젝트에 의해 결정됩니다.

  • 구성 변경사항: 환경 변수에서 더 이상 ads.properties의 api.googleads.developerToken 또는 GOOGLE_ADS_DEVELOPER_TOKEN을 지정하지 않아도 됩니다. api.googleads.developerToken를 계속 지정하는 기존 애플리케이션은 API 서버가 developer-token 헤더를 무시하므로 계속 작동합니다 (향후 메이저 버전의 Google Ads API에서는 거부됨).
  • 클라이언트 라이브러리 버전 요구사항: 구성에서 개발자 토큰을 생략하려면 개발자 토큰이 필요한 클라이언트 측 유효성 검사를 삭제한 google-ads-java v46.0.0 이상을 사용하세요.
  • 승인 오류 변경사항: 테스트 액세스 권한만 있는 Google Cloud 프로젝트에서 프로덕션 Google Ads 계정을 호출하는 경우 Google Ads API의 v25 이상에서는 AuthorizationError.CLOUD_PROJECT_NOT_APPROVED_FOR_PRODUCTION를 반환하는 반면 v24 이하에서는 AuthorizationError.ACTION_NOT_PERMITTED를 반환합니다.