[英]Calling SOAP client(suds) in python returning error AuthenticationError.LOGIN_COOKIE_REQUIRED
[英]Getting authenticationerror.login_cookie_required error while using Google adwords API with Python
我正在嘗試使用python來使用一些adwords soap API,我能夠獲取auth令牌,但是當我嘗試發出get請求時,出現了authenticationerror.login_cookie_required錯誤。 有任何想法嗎?
from suds.client import Client
auth_data = {'accountType':'GOOGLE', 'Email':'xxx@xxx.com', 'Passwd':'xxxxxxxx', 'service':'adwords', 'source':'xxxxxxxxxx'}
auth_data = urllib.urlencode(auth_data)
auth_request = urllib2.Request('https://www.google.com/accounts/ClientLogin', auth_data)
auth_response = urllib2.urlopen(auth_request)
auth_response = auth_response.read()
split = auth_response.split('=')
auth_token = split[len(split)-1]
url = 'https://adwords-sandbox.google.com/api/adwords/cm/v201109/CampaignService?wsdl'
client = Client(url)
authToken = auth_token
developerToken = 'xxx@xxx.com++NZD'
userAgent = 'jameslin-python'
client.set_options(soapheaders=(authToken,developerToken,userAgent))
client.service.get()
您是否嘗試過將Python客戶端庫用於AdWords API? http://code.google.com/p/google-api-ads-python/
authToken不是SOAP標頭。 RequestHeader是Soap標頭,而authToken是該標頭的成員。 有關更多詳細信息,請參見http://code.google.com/apis/adwords/docs/headers.html和http://code.google.com/apis/adwords/docs/#soap 。
我還要指出,AdWords API官方論壇是http://groups.google.com/group/adwords-api ,我們在那里定期回答有關AdWords API的問題。 如果您有任何后續問題,請隨時在官方論壇上提問。
干杯,阿納什
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.