# Get the Google Ads Client. By default, any credentials will be 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();
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-05 (世界標準時間)。"],[[["\u003cp\u003eThe Google Ads API Client library for Perl offers flexible configuration options, including using a \u003ccode\u003egoogleads.properties\u003c/code\u003e file, dynamic settings during instantiation, or environment variables.\u003c/p\u003e\n"],["\u003cp\u003eYou can specify a \u003ccode\u003egoogleads.properties\u003c/code\u003e file to store your client ID, client secret, and refresh token for authentication, either by default in your home directory or by providing a specific file path.\u003c/p\u003e\n"],["\u003cp\u003eDynamically configure the client by setting parameters like \u003ccode\u003edeveloper_token\u003c/code\u003e and \u003ccode\u003elogin_customer_id\u003c/code\u003e during or after instantiation using provided methods.\u003c/p\u003e\n"],["\u003cp\u003eUtilize environment variables to set configuration settings, ensuring they are set beforehand, and use the \u003ccode\u003econfigure_from_environment_variables\u003c/code\u003e function to load them into the client.\u003c/p\u003e\n"],["\u003cp\u003eThe client library supports key configuration fields such as \u003ccode\u003eclient_id\u003c/code\u003e, \u003ccode\u003eclient_secret\u003c/code\u003e, \u003ccode\u003erefresh_token\u003c/code\u003e, \u003ccode\u003edeveloper_token\u003c/code\u003e, \u003ccode\u003elogin_customer_id\u003c/code\u003e, and \u003ccode\u003eproxy\u003c/code\u003e for customizing its behavior.\u003c/p\u003e\n"]]],[],null,["# Configuration\n\nAds API Client library provides several configuration settings that you can use\nto customize the library behavior.\n\nConfiguration file\n------------------\n\nYou can specify a\n[`googleads.properties`](https://github.com/googleads/google-ads-perl/blob/HEAD/googleads.properties)\nfile to use when instantiating the client.\n\nIf you use no arguments when instantiating: \n\n my $api_client = Google::Ads::GoogleAds::Client-\u003enew();\n\nthen the library will look in your `HOME` directory for the file.\n\nAlternatively, you can specify a path: \n\n my $properties_file = \"/path/to/googleads.properties\";\n\n my $api_client = Google::Ads::GoogleAds::Client-\u003enew({\n properties_file =\u003e $properties_file\n });\n\nin which case the client will look for the file at that file path.\n\nThe easiest way to generate this file is to copy the `googleads.properties` from\nthe GitHub repository and modify it to include your client ID, client secret and\nrefresh token.\n\nDynamic configuration\n---------------------\n\nYou can set up the configuration dynamically when instantiating the library, or\neven afterwards: \n\n my $api_client = Google::Ads::GoogleAds::Client-\u003enew({\n developer_token =\u003e \"INSERT_DEVELOPER_TOKEN_HERE\",\n login_customer_id =\u003e \"INSERT_LOGIN_CUSTOMER_ID_HERE\"\n });\n\nYou can even modify the configuration after instantiation: \n\n $api_client-\u003eset_login_customer_id(\"INSERT_LOGIN_CUSTOMER_ID_HERE\");\n\nYou can also get a [OAuth2ApplicationsHandler](https://github.com/googleads/google-ads-perl/blob/HEAD/lib/Google/Ads/GoogleAds/OAuth2ApplicationsHandler.pm)\nobject from the `API Client`, and change the client ID, client secret and\nrefresh token at runtime: \n\n my $oauth2_applications_handler = $api_client-\u003eget_oauth2_applications_handler();\n $oauth2_applications_handler-\u003eset_client_id(\"INSERT_CLIENT_ID\");\n $oauth2_applications_handler-\u003eset_client_secret(\"INSERT_CLIENT_SECRET\");\n $oauth2_applications_handler-\u003eset_refresh_token(\"INSERT_REFRESH_TOKEN\");\n\nConfiguration environment variables\n-----------------------------------\n\nYou can set some of the configuration settings from environment variables when\ninstantiating clients (see the [exhaustive\nlist](/google-ads/api/docs/client-libs#configuration)).\n\nThe Client module provides the `configure_from_environment_variables`\nfunction to load values from environment variables:\n**Note:** Unset environment variables are *not* taken into account. \n\n # Get the Google Ads Client. By default, any credentials will be read from\n # ~/googleads.properties, or, if set, from the file specified in the\n # GOOGLE_ADS_CONFIGURATION_FILE_PATH environment variable.\n my $api_client = Google::Ads::GoogleAds::Client-\u003enew();\n\n # Load the configuration from any set environment variables.\n $api_client-\u003econfigure_from_environment_variables();\n\nConfiguration fields\n--------------------\n\nThe configuration properties support the following fields:\n\nFields persisted in [OAuth2ApplicationsHandler](https://github.com/googleads/google-ads-perl/blob/HEAD/lib/Google/Ads/GoogleAds/OAuth2ApplicationsHandler.pm):\n\n- `client_id`: Your OAuth2 client ID.\n- `client_secret`: Your OAuth2 client secret.\n- `refresh_token`: Your OAuth2 refresh token.\n\nFields persisted in [API Client](https://github.com/googleads/google-ads-perl/blob/HEAD/lib/Google/Ads/GoogleAds/Client.pm):\n\n- `developer_token`: Your developer token for accessing the API.\n- `login_customer_id`: See the [login-customer-id documentation](/google-ads/api/docs/concepts/call-structure#cid).\n- `proxy`: The proxy server URL used for internet connectivity."]]