Google Ads Api TransportError исключение - PullRequest
0 голосов
/ 28 марта 2020

Я пытаюсь разработать инструмент, использующий API-интерфейсы Google для рекламы, для управления кампаниями и составления отчетов для моей компании с помощью Python. Но я получаю исключение TransportError, как показано ниже

Request Method: GET
Request URL: http://127.0.0.1:8000/anasayfa/
Django Version: 3.0.4
Python Version: 3.8.0
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'musteri_bolumu']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback (most recent call last):
  File "C:\Users\A.Orbey\AppData\Local\Programs\Python\Python38-32\lib\site-packages\suds\transport\http.py", line 67, in open
    return self.u2open(u2request)
  File "C:\Users\A.Orbey\AppData\Local\Programs\Python\Python38-32\lib\site-packages\suds\transport\http.py", line 132, in u2open
    return url.open(u2request, timeout=tm)
  File "C:\Users\A.Orbey\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 531, in open
    response = meth(req, response)
  File "C:\Users\A.Orbey\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 640, in http_response
    response = self.parent.error(
  File "C:\Users\A.Orbey\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 569, in error
    return self._call_chain(*args)
  File "C:\Users\A.Orbey\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 502, in _call_chain
    result = func(*args)
  File "C:\Users\A.Orbey\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)

During handling of the above exception (HTTP Error 404: Not Found), another exception occurred:
  File "C:\Users\A.Orbey\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
    response = get_response(request)
  File "C:\Users\A.Orbey\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "C:\Users\A.Orbey\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "C:\Users\A.Orbey\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\contrib\auth\decorators.py", line 21, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "D:\projeler\google_adwords\musteri_bolumu\views.py", line 46, in anasayfa
    campaign_service = client.GetService('CampaignService')
  File "C:\Users\A.Orbey\AppData\Local\Programs\Python\Python38-32\lib\site-packages\googleads\adwords.py", line 303, in GetService
    client = suds.client.Client(
  File "C:\Users\A.Orbey\AppData\Local\Programs\Python\Python38-32\lib\site-packages\suds\client.py", line 115, in __init__
    self.wsdl = reader.open(url)
  File "C:\Users\A.Orbey\AppData\Local\Programs\Python\Python38-32\lib\site-packages\suds\reader.py", line 150, in open
    d = self.fn(url, self.options)
  File "C:\Users\A.Orbey\AppData\Local\Programs\Python\Python38-32\lib\site-packages\suds\wsdl.py", line 136, in __init__
    d = reader.open(url)
  File "C:\Users\A.Orbey\AppData\Local\Programs\Python\Python38-32\lib\site-packages\suds\reader.py", line 74, in open
    d = self.download(url)
  File "C:\Users\A.Orbey\AppData\Local\Programs\Python\Python38-32\lib\site-packages\suds\reader.py", line 92, in download
    fp = self.options.transport.open(Request(url))
  File "C:\Users\A.Orbey\AppData\Local\Programs\Python\Python38-32\lib\site-packages\suds\transport\https.py", line 62, in open
    return HttpTransport.open(self, request)
  File "C:\Users\A.Orbey\AppData\Local\Programs\Python\Python38-32\lib\site-packages\suds\transport\http.py", line 69, in open
    raise TransportError(str(e), e.code, e.fp)

Exception Type: TransportError at /anasayfa/
Exception Value: HTTP Error 404: Not Found

мой код выглядит следующим образом:

client = adwords.AdWordsClient.LoadFromStorage() //call googleads.yaml file
campaign_service = client.GetService('CampaignService')

мой файл googleads.yaml выглядит следующим образом:

# AdWordsClient configurations
adwords:
  #############################################################################
  # Required Fields                                                           #
  #############################################################################
  developer_token: <REDACTED>
  #############################################################################
  # Optional Fields                                                           #
  #############################################################################
  #client_customer_id: 644-880-2249
  user_agent: WebFirmam
  # partial_failure: True
  # validate_only: True
  #############################################################################
  # OAuth2 Configuration                                                      #
  # Below you may provide credentials for either the installed application or #
  # service account flows. Remove or comment the lines for the flow you're    #
  # not using.                                                                #
  #############################################################################
  # The following values configure the client for the installed application
  # flow.
  client_id: 282327658670-bn8affhv8l4na1cln728qlst5gg6p2th.apps.googleusercontent.com
  client_secret: <REDACTED>
  refresh_token: <REDACTED>
  # The following values configure the client for the service account flow.
  # path_to_private_key_file: INSERT_PATH_TO_JSON_KEY_FILE_HERE
  # delegated_account: INSERT_DOMAIN_WIDE_DELEGATION_ACCOUNT
  #############################################################################
  # ReportDownloader Headers                                                  #
  # Below you may specify boolean values for optional headers that will be    #
  # applied to all requests made by the ReportDownloader utility by default.  #
  #############################################################################
  # report_downloader_headers:
    # skip_report_header: False
    # skip_column_header: False
    # skip_report_summary: False
    # use_raw_enum_values: False


# AdManagerClient configurations
ad_manager:
  #############################################################################
  # Required Fields                                                           #
  #############################################################################
  #application_name: INSERT_APPLICATION_NAME_HERE
  #############################################################################
  # Optional Fields                                                           #
  #############################################################################
  # The network_code is required for all services except NetworkService:
  # network_code: INSERT_NETWORK_CODE_HERE
  # delegated_account: INSERT_DOMAIN_WIDE_DELEGATION_ACCOUNT
  #############################################################################
  # OAuth2 Configuration                                                      #
  # Below you may provide credentials for either the installed application or #
  # service account (recommended) flows. Remove or comment the lines for the  #
  # flow you're not using.                                                    #
  #############################################################################
  # The following values configure the client for the service account flow.
  #path_to_private_key_file: INSERT_PATH_TO_JSON_KEY_FILE_HERE
  # delegated_account: INSERT_DOMAIN_WIDE_DELEGATION_ACCOUNT
  # The following values configure the client for the installed application
  # flow.
  # client_id: INSERT_OAUTH_2_CLIENT_ID_HERE
  # client_secret: INSERT_CLIENT_SECRET_HERE
  # refresh_token: INSERT_REFRESH_TOKEN_HERE


# Common configurations:
###############################################################################
# Compression (optional)                                                      #
# Below you may specify whether to accept and automatically decompress gzip   #
# encoded SOAP requests. By default, gzip compression is not enabled.         #
###############################################################################
# enable_compression: False
###############################################################################
# Logging configuration (optional)                                            #
# Below you may specify the logging configuration. This will be provided as   #
# an input to logging.config.dictConfig.                                      #
###############################################################################
# logging:
  # version: 1
  # disable_existing_loggers: False
  # formatters:
    # default_fmt:
      # format: ext://googleads.util.LOGGER_FORMAT
  # handlers:
    # default_handler:
      # class: logging.StreamHandler
      # formatter: default_fmt
      # level: INFO
  # loggers:
    # Configure root logger
    # "":
      # handlers: [default_handler]
      # level: INFO
###############################################################################
# Proxy configurations (optional)                                             #
# Below you may specify an HTTP or HTTPS Proxy to be used when making API     #
# requests. Note: You must specify the scheme used for the proxy endpoint.    #
#                                                                             #
# For additional information on configuring these values, see:                #
# http://docs.python-requests.org/en/master/user/advanced/#proxies            #
###############################################################################
# proxy_config:
  # http: INSERT_HTTP_PROXY_URI_HERE
  # https: INSERT_HTTPS_PROXY_URI_HERE
  # If specified, the given cafile will only be used if certificate validation
  # is not disabled.
  # cafile: INSERT_PATH_HERE
  # disable_certificate_validation: False
################################################################################
# Utilities Included (optional)                                                #
# Below you may specify whether the library will include utilities used in the #
# user agent. By default, the library will include utilities used in the user  #
# agent.                                                                       #
################################################################################
# include_utilities_in_user_agent: True
################################################################################
# Custom HTTP headers (optional)                                               #
# Specify one or more custom headers to pass along with all requests to        #
# the API.                                                                     #
################################################################################
# custom_http_headers:
#   X-My-Header: 'content'

Где это ошибка, которую я сделал, я не понимаю, так может ли кто-нибудь мне помочь?

...