2011-11-13 7 views
0

Firefoxの一部を消費するためにPythonを使用しようとしていますが、認証トークンを取得できます。 login_cookie_requiredエラー。何か案は?GoogleのAdWords APIをPythonで使用しているときにauthenticationerror.login_cookie_requiredエラーが発生しました

from suds.client import Client 

auth_data = {'accountType':'GOOGLE', 'Email':'[email protected]', '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 = '[email protected]++NZD' 
userAgent = 'jameslin-python' 
client.set_options(soapheaders=(authToken,developerToken,userAgent)) 
client.service.get() 

答えて

0

AdWords API用のPythonクライアントライブラリを使用しようとしましたか? http://code.google.com/p/google-api-ads-python/

+0

はい、それは働いていたが、私は直接SOAPサービスを利用しようとしていました –

0

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に関する質問に回答しています。フォローアップの質問がある場合は、公式フォーラムでお気軽にお問い合わせください。

乾杯、 Anash

関連する問題