কনফিগারেশন

Java ক্লায়েন্ট লাইব্রেরি ads.properties নামের একটি কনফিগারেশন ফাইল আপনার হোম ডিরেক্টরিতে (System.getProperty("user.home") + "/ads.properties" অথবা ~/ads.properties) খোঁজে। আপনি রানটাইমে এই পাথ ও ফাইলের নাম ওভাররাইড করতে পারেন, যখন নিম্নলিখিত মেকানিজমগুলির যেকোনও একটি ব্যবহার করে GoogleAdsClient তৈরি করা হয়:

  • কল fromPropertiesFile(PATH_TO_CONFIG_FILE), যেখানে PATH_TO_CONFIG_FILE হল আপনার কনফিগারেশন ফাইলের File পাথ ও ফাইলের নাম।
  • এনভায়রনমেন্ট ভেরিয়েবেল GOOGLE_ADS_CONFIGURATION_FILE_PATH আপনার কনফিগারেশন ফাইলের পাথ ও ফাইলের নামে সেট করুন এবং তারপর fromPropertiesFile() কল করুন।

কনফিগারেশন ফাইলের ফর্ম্যাট হল 'কী-ভ্যালু' পেয়ারের স্ট্যান্ডার্ড জাভা প্রপার্টি ফাইল। বেছে নেওয়া যাচাইকরণ ফ্লো অনুযায়ী সাপোর্ট করা কী আলাদা আলাদা হয়।

ডেস্কটপ ও ওয়েব অ্যাপ্লিকেশন ফ্লোয়ের জন্য কাজ করে এমন কী

আপনি সিঙ্গেল-ইউজার বা মাল্টি-ইউজার অ্যাপ্লিকেশন ফ্লো ব্যবহার করলে, মানানসই কীগুলি হল নিম্নলিখিত:

# 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

আপনি উপযুক্ত এনভায়রনমেন্ট ভেরিয়েবেল সেট করার পরে, বিল্ডারে fromEnvironment() কল করে আপনার GoogleAdsClient কনফিগার করুন:

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

কনফিগারেশন সংক্রান্ত বিভিন্ন পদ্ধতিকে একত্রিত করা

GoogleAdsClient এবং এর বিল্ডার বিভিন্ন কনফিগারেশন স্ট্র্যাটেজি একত্রিত করার সুবিধা দেয়। যেমন, আপনি ইনস্ট্যান্সের ক্রেডেনশিয়াল কনফিগার করতে এনভায়রনমেন্ট ভেরিয়েবল এবং অন্যান্য অ্যাট্রিবিউটের জন্য প্রপার্টি ফাইল ব্যবহার করতে পারেন। এর জন্য নিম্নলিখিত স্নিপেট ব্যবহার করুন:

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

build() কল করার আগে বিল্ডারের অন্যান্য কনফিগারেশন পদ্ধতি ব্যবহার করে আপনি রানটাইমে আরও পরিবর্তন করতে পারবেন।