লাইব্রেরিটি 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
# 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
# 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 |
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();
এই উদাহরণে, ক্লায়েন্ট লাইব্রেরি প্রোপার্টি ফাইলের মান ব্যবহার করবে যেকোনো অ্যাট্রিবিউটের জন্য যা তার এনভায়রনমেন্ট ভেরিয়েবল এবং প্রোপার্টি ফাইলের একটি এন্ট্রি উভয়ের মাধ্যমেই সংজ্ঞায়িত করা হয়েছে। বিপরীত আচরণের জন্য, fromPropertiesFile() কে fromEnvironment() এর আগে কল করুন।
build() কল করার আগে বিল্ডারের অন্যান্য কনফিগারেশন পদ্ধতি ব্যবহার করে রানটাইমে আপনি আরও পরিবর্তন করতে পারেন।