구성

Google Ads API Perl 클라이언트 라이브러리는 라이브러리 동작을 맞춤설정하는 데 사용할 수 있는 여러 구성 설정을 제공합니다.

구성 파일

클라이언트를 인스턴스화할 때 사용할 googleads.properties 파일을 지정할 수 있습니다.

인수 없이 인스턴스화하는 경우:

my $api_client = Google::Ads::GoogleAds::Client->new();

라이브러리는 HOME 디렉터리에서 파일을 찾거나, GOOGLE_ADS_CONFIGURATION_FILE_PATH 환경 변수가 설정된 경우 해당 변수에 지정된 경로에서 파일을 찾습니다.

또는 경로를 명시적으로 지정할 수 있습니다.

my $properties_file = "/path/to/googleads.properties";

my $api_client = Google::Ads::GoogleAds::Client->new({
  properties_file => $properties_file,
});

이 경우 클라이언트는 해당 경로에서 파일을 찾습니다.

이 파일을 생성하는 가장 쉬운 방법은 GitHub 저장소에서 googleads.properties를 복사하고 클라이언트 ID, 클라이언트 보안 비밀번호, 갱신 토큰을 포함하도록 수정하는 것입니다.

동적 구성

라이브러리를 인스턴스화할 때 또는 인스턴스화한 후에 구성을 동적으로 설정할 수 있습니다.

my $api_client = Google::Ads::GoogleAds::Client->new({
  login_customer_id => "INSERT_LOGIN_CUSTOMER_ID_HERE",
});

인스턴스화 후 구성을 수정할 수도 있습니다.

$api_client->set_login_customer_id("INSERT_LOGIN_CUSTOMER_ID_HERE");

Client 인스턴스에서 OAuth2ApplicationsHandler 객체를 가져와 런타임에 클라이언트 ID, 클라이언트 보안 비밀번호, 갱신 토큰을 변경할 수도 있습니다.

my $oauth2_applications_handler =
  $api_client->get_oauth2_applications_handler();
$oauth2_applications_handler->set_client_id("INSERT_CLIENT_ID_HERE");
$oauth2_applications_handler->set_client_secret("INSERT_CLIENT_SECRET_HERE");
$oauth2_applications_handler->set_refresh_token("INSERT_REFRESH_TOKEN_HERE");

구성 환경 변수

클라이언트를 인스턴스화할 때 환경 변수에서 일부 구성 설정을 설정할 수 있습니다 (표준 환경 변수 참고).

Client 모듈은 환경 변수에서 값을 로드하는 configure_from_environment_variables 함수를 제공합니다.

# Get the Google Ads API Client. By default, any credentials are read from
# ~/googleads.properties, or, if set, from the file specified in the
# GOOGLE_ADS_CONFIGURATION_FILE_PATH environment variable.
my $api_client = Google::Ads::GoogleAds::Client->new();

# Load the configuration from any set environment variables.
$api_client->configure_from_environment_variables();

구성 필드

googleads.properties 키는 camelCase (예: loginCustomerId 및 linkedCustomerId)를 사용하는 반면 Client->new({...}) 생성자 인수 및 핸들러 메서드는 snake_case (예: login_customer_id 및 linked_customer_id)를 사용합니다.

OAuth2ApplicationsHandler에 유지되는 필드:

  • client_id (googleads.properties, GOOGLE_ADS_CLIENT_ID의 clientId): OAuth2 클라이언트 ID입니다.
  • client_secret (googleads.properties, GOOGLE_ADS_CLIENT_SECRET의 경우 clientSecret): OAuth2 클라이언트 보안 비밀번호입니다.
  • refresh_token (googleads.properties, GOOGLE_ADS_REFRESH_TOKEN의 refreshToken): OAuth2 갱신 토큰입니다.
  • additional_scopes (googleads.properties의 additionalScopes): 요청할 추가 OAuth2 범위입니다.

OAuth2ServiceAccountsHandler에 유지되는 필드:

  • json_key_file_path (googleads.properties, GOOGLE_ADS_JSON_KEY_FILE_PATH의 jsonKeyFilePath): 서비스 계정 JSON 키 파일의 경로입니다.
  • impersonated_email (googleads.properties, GOOGLE_ADS_IMPERSONATED_EMAIL의 impersonatedEmail): Google Workspace 도메인 전체 위임을 사용할 때 가장할 이메일 주소입니다.
  • additional_scopes (googleads.properties의 additionalScopes): 요청할 추가 OAuth2 범위입니다.

Client에 유지되는 필드:

  • developer_token (googleads.properties, GOOGLE_ADS_DEVELOPER_TOKEN의 developerToken): (2026년 9월 9일 지원 종료) Google Ads API 개발자 토큰입니다. 선택사항이며, 클라이언트 라이브러리 버전에 관계없이 API 서버에서 무시되고 향후 Google Ads API의 메이저 버전에서 거부됩니다.
    • v35.0.0 이상: 클라이언트 초기화 시 필요하지 않습니다 (로컬 클라이언트 측 developerToken 검증이 v35.0.0에서 삭제됨).
    • v35.0.0 이전 버전: v35.0.0 이상으로 업그레이드하지 않은 경우 로컬 클라이언트 측 구성 유효성 검사에 필요합니다.
  • login_customer_id (googleads.properties, GOOGLE_ADS_LOGIN_CUSTOMER_ID의 loginCustomerId): 고객 계정에 액세스하는 데 사용되는 관리자 계정의 ID입니다. login-customer-id 문서를 참고하세요.
  • linked_customer_id (googleads.properties, GOOGLE_ADS_LINKED_CUSTOMER_ID의 linkedCustomerId): 연결된 고객 ID입니다.
  • service_address (googleads.properties, GOOGLE_ADS_ENDPOINT의 경우 serviceAddress): Google Ads API 서비스 주소 URL입니다 (기본값은 "https://googleads.googleapis.com").
  • user_agent (googleads.properties, GOOGLE_ADS_PERL_USER_AGENT의 userAgent): HTTP 요청에 포함된 맞춤 사용자 에이전트 헤더 접두사입니다.
  • proxy (googleads.properties, GOOGLE_ADS_PERL_PROXY의 proxy): 인터넷 연결에 사용되는 프록시 서버 URL입니다.
  • version (Client->new 또는 set_version): 사용할 Google Ads API 버전 모듈입니다 (기본값은 "V25").
  • die_on_faults(Client->new 또는 set_die_on_faults): 서비스 메서드가 API 오류 시 원시 응답 페이로드를 사용하여 die()를 호출하도록 1로 설정합니다(Google::Ads::GoogleAds::GoogleAdsException 객체를 반환하는 대신)(기본값은 0).
  • http_timeout (Client->new 또는 set_http_timeout): 초 단위의 HTTP 제한 시간입니다 (기본값은 3600).
  • http_retry_timing(Client->new 또는 set_http_retry_timing): 일시적인 HTTP 503 및 504 오류의 재시도 일시중지 간격(초)(기본값은 "5,10,15")입니다.