কনফিগারেশন

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

  • fromPropertiesFile(PATH_TO_CONFIG_FILE) কল করুন, যেখানে PATH_TO_CONFIG_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

# Token which provides access to the Google Ads API in general. It does not
# grant access to any particular ad account (OAuth is used for this purpose).
api.googleads.developerToken=INSERT_DEVELOPER_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

পরিষেবা অ্যাকাউন্টের জন্য সমর্থিত কী

আপনি যদি পরিষেবা অ্যাকাউন্ট প্রবাহ ব্যবহার করেন, তাহলে সমর্থিত কীগুলি নিম্নরূপ:

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

# Email address of the user to impersonate.
# This should be a user who has access to your Google Ads account and is in the same
# Google Apps Domain as the service account.
api.googleads.serviceAccountUser=INSERT_USER_EMAIL_ADDRESS_HERE

# Token which provides access to the Google Ads API in general. It does not
# grant access to any particular ad account (OAuth is used for this purpose).
api.googleads.developerToken=INSERT_DEVELOPER_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

পরিবেশ ভেরিয়েবল ব্যবহার করে

লাইব্রেরি সমস্ত Google Ads API ক্লায়েন্ট লাইব্রেরিতে সাধারণ সমস্ত পরিবেশ ভেরিয়েবল সমর্থন করে। নীচের টেবিলটি পরিবেশের পরিবর্তনশীল দেখায় যা প্রতিটি কনফিগারেশন ফাইল সম্পত্তির সাথে মিলে যায়।

কনফিগারেশন ফাইল সম্পত্তি পরিবেশ সূচক
api.googleads.developerToken GOOGLE_ADS_DEVELOPER_TOKEN
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

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

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

কনফিগারেশন পদ্ধতির সমন্বয়

GoogleAdsClient এবং এর নির্মাতা বিভিন্ন কনফিগারেশন কৌশলের সমন্বয়ে সমর্থন করে। উদাহরণস্বরূপ, আপনি নিম্নলিখিত স্নিপেট ব্যবহার করে উদাহরণের শংসাপত্র এবং অন্যান্য বৈশিষ্ট্যগুলির জন্য একটি বৈশিষ্ট্য ফাইল কনফিগার করতে পরিবেশ ভেরিয়েবল ব্যবহার করতে পারেন।

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

এই উদাহরণে, ক্লায়েন্ট লাইব্রেরি বৈশিষ্ট্য ফাইল থেকে মান ব্যবহার করবে যে কোনও বৈশিষ্ট্যের জন্য যা তার এনভায়রনমেন্ট ভেরিয়েবল এবং বৈশিষ্ট্য ফাইলের একটি এন্ট্রি উভয়ের মাধ্যমে সংজ্ঞায়িত করা হয়েছে। বিপরীত আচরণের জন্য, কেবলমাত্র fromEnvironment() থেকে fromPropertiesFile() কল করুন।

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