BingAds / BingAds-Python-SDK

Other
118 stars 164 forks source link

Proxy Issue #14

Closed fdosani closed 8 years ago

fdosani commented 8 years ago

Hi there,

I'm running into an issue as I'm behind a corp proxy. I'm trying to generate reports using the ReportingService feature. I've been passing the proxy as follows when constructing ReportingServiceManager and ServiceClient as so:

reporting_service_manager=ReportingServiceManager(
        authorization_data=authorization_data, 
        poll_interval_in_milliseconds=5000, 
        environment=ENVIRONMENT,
        proxy={'https': 'user:pass@mycorpproxy.com:1234'}
    )

 reporting_service=ServiceClient(
        'ReportingService', 
        authorization_data=authorization_data, 
        environment=ENVIRONMENT,
        version=9,
        proxy={'https': 'user:pass@mycorpproxy.com:1234'}
    )

This will pass the proxy input to the SUDS Client in the background so the call can be made. Makes sense and works as it should.

the problem occurs when making the submit_download request and the subsequent pooling which occurs when a call is made to the ReportingDownloadOperation class.

The ReportingDownloadOperation class takes the **suds_options in the constructor to pass to the ServiceClient which is great but it seems like the proxy setting are never passed in the following line of code.

https://github.com/BingAds/BingAds-Python-SDK/blob/master/bingads/reporting/reporting_service_manager.py#L91

Is there a work around for this that I'm missing? If I hack the code base a bit I can get it to work like this

def submit_download(self, report_request, http_proxy):
        """ Submits a download request to the Bing Ads reporting service with the specified request.
        :param report_request: Determines what kind of reporting file to download
        :type report_request: ReportRequest
        :return: The submitted download operation
        :rtype: ReportingDownloadOperation
        """
        response = self.service_client.SubmitGenerateReport(report_request)
        operation = ReportingDownloadOperation(
            request_id=response,
            authorization_data=self._authorization_data,
            poll_interval_in_milliseconds=self._poll_interval_in_milliseconds,
            environment=self._environment,
            location=self.service_client.service_url,
            proxy=http_proxy
        )
        return operation

Without this I can never get past the proxy and download the file. It works if I'm not behind a proxy. I feel like the submit_download method would benefit from a **suds_options kwarg too maybe?

Thanks, Faisal

imagineful commented 8 years ago

Hi, fdosani, thanks for your feedback. we will consider to add suds options in these public methods in next release (not only for proxy). Full suds options are supported in ReportingServiceManager/BulkServiceManager/*Download/UploadOperations constructors, currently for the main high level methods, only passes location parameters. the fix will pass all suds parameters to the public methods, but will not impact the methods definition (no new parameters will be introduced in the methods).

Thanks. Li.

fdosani commented 8 years ago

Thanks appreciate it Li!

imagineful commented 8 years ago

Hi, version 10.4.3 has been released, it should include the fix of this issue. Thanks. Li.

fdosani commented 8 years ago

Thanks for fixing this. I've tested it on my end and all seems to be working now :)