تهيئة مكتبة عميل جافا

تبحث المكتبة عن ملف إعداد في System.getProperty("user.home") + "/searchads360.properties".

يكون تنسيق ملف الإعداد على شكل ملف Properties من Java يحتوي على أزواج المفاتيح والقيم. تختلف المفاتيح المتوافقة حسب مسار المصادقة الذي تم اختياره.

المفاتيح المتوافقة مع مسارات تطبيقات الكمبيوتر المكتبي والويب

إذا كنت تستخدم مسار تطبيق الكمبيوتر المكتبي أو الويب، تكون المفاتيح المتوافقة كما يلي:

# Credential for accessing Google's OAuth servers.
# Provided by console.cloud.google.com.
api.searchads360.clientId=INSERT_CLIENT_ID_HERE

# Credential for accessing Google's OAuth servers.
# Provided by console.cloud.google.com.
api.searchads360.clientSecret=INSERT_CLIENT_SECRET_HERE

# Renewable OAuth credential associated with 1 or more Search Ads accounts.
api.searchads360.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.searchads360.loginCustomerId=INSERT_LOGIN_CUSTOMER_ID_HERE


الجمع بين طرق الإعداد

تتيح السمة SearchAds360Client وأداة الإنشاء الخاصة بها إمكانية الجمع بين استراتيجيات إعدادات مختلفة. على سبيل المثال، يمكنك استخدام ملف خصائص لضبط بيانات اعتماد المثيل وسمات أخرى باستخدام المقتطف التالي.

SearchAds360Client searchAds360Client = SearchAds360Client.newBuilder()
    .fromPropertiesFile()
    .build();

يمكنك إجراء المزيد من التغييرات في وقت التشغيل باستخدام طرق الضبط الأخرى الخاصة بأداة الإنشاء قبل استدعاء build().

إذا كنت بصدد إثبات الهوية كحساب إداري، عليك أيضًا تحديد ما يلي:

api.searchads360.loginCustomerId --> Manager account ID (with hyphens removed).