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