2016-03-07 90 views
1

我似乎無法連接Adwords API。我遵循的步驟如下所述:https://developers.google.com/adwords/api/docs/first-requestPython Adwords API身份驗證問題

文件所在的文件夾C:\用戶\用戶\文檔\ googleads的Python-lib的主\ 和認證文件(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 
+1

https://github.com/googleads/googleads-python-lib/issues/10 – fabrigm

+0

感謝您的評論。所以,如果我理解正確,那麼在Python 3.x中使用OAuth2進行身份驗證是不可能的? – Dendrobates

+0

看來,是的... – fabrigm

回答

0

一些進一步的研究解決了這個問題。 Fabrigm已經幫助我朝着正確的方向前進。謝謝!

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

當您瀏覽其他releases of the library時,您會發現Python 2.x和3.x的示例。用Python 3.x編寫的代碼工作得非常好,但是(至少對我來說)很容易犯這個錯誤,並且繼續使用其他版本。

我希望這可能會幫助其他人解決同樣的問題。