1313# limitations under the License.
1414"""A client and common configurations for the Google Ads API."""
1515
16- import grpc
16+ from grpc import intercept_channel
1717from importlib import import_module
1818import logging .config
1919
@@ -194,7 +194,7 @@ def __init__(self, credentials, developer_token, endpoint=None,
194194 self .endpoint = endpoint
195195 self .login_customer_id = login_customer_id
196196
197- def get_service (self , name , version = _DEFAULT_VERSION ):
197+ def get_service (self , name , version = _DEFAULT_VERSION , interceptors = [] ):
198198 """Returns a service client instance for the specified service_name.
199199
200200 Args:
@@ -203,6 +203,9 @@ def get_service(self, name, version=_DEFAULT_VERSION):
203203 "CampaignService" to retrieve a CampaignServiceClient instance.
204204 version: a str indicating the version of the Google Ads API to be
205205 used.
206+ interceptors: an optional list of interceptors to include in
207+ requests. NOTE: this parameter is not intended for non-Google
208+ use and is not officially supported.
206209
207210 Returns:
208211 A service client instance associated with the given service_name.
@@ -234,12 +237,14 @@ def get_service(self, name, version=_DEFAULT_VERSION):
234237 credentials = self .credentials ,
235238 options = _GRPC_CHANNEL_OPTIONS )
236239
237- channel = grpc .intercept_channel (
238- channel ,
240+ interceptors = interceptors + [
239241 MetadataInterceptor (self .developer_token , self .login_customer_id ),
240242 LoggingInterceptor (_logger , endpoint ),
241- ExceptionInterceptor (version )
242- )
243+ ExceptionInterceptor (version )]
244+
245+ channel = intercept_channel (
246+ channel ,
247+ * interceptors )
243248
244249 service_transport = service_transport_class (channel = channel )
245250
0 commit comments