簡體   English   中英

Python Adwords API身份驗證問題

[英]Python Adwords API authentication issue

我似乎無法與Adwords API連接。 我按照此處描述的步驟進行操作: https : //developers.google.com/adwords/api/docs/first-request

文件位於文件夾C:\\ Users \\ User \\ Documents \\ googleads-python-lib-master \\中,並且使用我的帳戶設置填充了身份驗證文件(googleads.yaml)。 這些帳戶設置以前在Java環境中有效。

關於出什么問題有什么建議嗎?

我正在使用Python 3.5.1和適用於Python的最新Adwords API。

我收到的錯誤代碼是:

C:/Users/User/Documents/googleads-python-lib-master/examples/adwords/v201509/basic_operations/get_campaigns.py
INFO:oauth2client.client:Refreshing access_token
DEBUG:suds.transport.http:opening (https://adwords.google.com/api/adwords/cm/v201509/CampaignService?wsdl)
DEBUG:suds.transport.http:sending:
URL: https://adwords.google.com/api/adwords/cm/v201509/CampaignService
HEADERS: {'Content-Type': 'text/xml; charset=utf-8', 'Content-type': 'text/xml; charset=utf-8', 'Soapaction': b'""', 'SOAPAction': b'""', 'Authorization': 'Bearer ya29.ngJKUmqHAKGfa93lSHVcYtpj6IHzN9KAoaMhGS_LEZJvrJjHnEl8Kx83leap3ae-g_zHmzA'}
MESSAGE:
b'<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="https://adwords.google.com/api/adwords/cm/v201509" xmlns:ns1="https://adwords.google.com/api/adwords/cm/v201509" xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Header><tns:RequestHeader><tns:developerToken>xxxxxxxxxxxxx</tns:developerToken><tns:userAgent>Client name (AwApi-Python, googleads/3.11.0, Python/3.5.1)</tns:userAgent><tns:validateOnly>false</tns:validateOnly><tns:partialFailure>false</tns:partialFailure></tns:RequestHeader></SOAP-ENV:Header><ns0:Body><ns1:get><ns1:serviceSelector><ns1:fields>Id</ns1:fields><ns1:fields>Name</ns1:fields><ns1:fields>Status</ns1:fields><ns1:paging><ns1:startIndex>0</ns1:startIndex><ns1:numberResults>100</ns1:numberResults></ns1:paging></ns1:serviceSelector></ns1:get></ns0:Body></SOAP-ENV:Envelope>'
ERROR:suds.client:<suds.sax.document.Document object at 0x03F01390>
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python35-32\lib\site-packages\suds_jurko-0.6-py3.5.egg\suds\transport\http.py", line 82, in send
  File "C:\Users\User\AppData\Local\Programs\Python\Python35-32\lib\site-packages\suds_jurko-0.6-py3.5.egg\suds\transport\http.py", line 132, in u2open
  File "C:\Users\User\AppData\Local\Programs\Python\Python35-32\lib\urllib\request.py", line 471, in open
    response = meth(req, response)
  File "C:\Users\User\AppData\Local\Programs\Python\Python35-32\lib\urllib\request.py", line 581, in http_response
    'http', request, response, code, msg, hdrs)
  File "C:\Users\User\AppData\Local\Programs\Python\Python35-32\lib\urllib\request.py", line 509, in error
    return self._call_chain(*args)
  File "C:\Users\User\AppData\Local\Programs\Python\Python35-32\lib\urllib\request.py", line 443, in _call_chain
    result = func(*args)
  File "C:\Users\User\AppData\Local\Programs\Python\Python35-32\lib\urllib\request.py", line 589, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 500: Internal Server Error

通過進一步研究解決了該問題。 Fabrigm已經幫助了我正確的方向。 謝謝!

Google Adwords API有多個版本,適用於Python 2.x和3.x。 雖然在Github上獲得最新版本時,您將獲得Google的適用於Python 2.x的Ads API的Python客戶端庫。

當您瀏覽該庫的其他發行版時 ,您將找到Python 2.x和3.x的示例。 用Python 3.x編寫的腳本絕對可以正常工作,但是(至少對我來說)很容易犯錯並繼續開發另一個版本。

我希望這可以幫助遇到同樣問題的其他人。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM