简体   繁体   English

python肥皂水验证到会员窗口

[英]python soap suds authenticate to affiliatewindow

I try to use the affiliatewindow - https://www.affiliatewindow.com - api with python. 我尝试将affiliatewindow- https ://www.affiliatewindow.com-api与python结合使用。 http://v3.core.com.productserve.com/ProductServeService.wsdl http://v3.core.com.productserve.com/ProductServeService.wsdl

In the documentation: 在文档中:

The authentication SOAP-Header element must be sent with every single request. 认证SOAP-Header元素必须与每个单个请求一起发送。

sApiKey (required) User specific key to authenticate user (ProductServe API (ShopWindow Client) Password) Value Type: String sApiKey(必需),用于验证用户的用户特定密钥(ProductServe API(ShopWindow客户端)密码)值类型:字符串

but it does not give any example of how this header will look. 但它没有提供有关此标头外观的任何示例。

My code: 我的代码:

from suds.xsd.doctor import ImportDoctor, Import
from suds.client import Client

imp = Import('http://schemas.xmlsoap.org/soap/encoding/')
imp.filter.add('http://v3.core.com.productserve.com/')
d = ImportDoctor(imp)
url = 'http://v3.core.com.productserve.com/ProductServeService.wsdl'

client = Client(url, doctor=d) 

ssn =   '<urn:sApiKey>[the-api-key]</urn:sApiKey>'
client.set_options(soapheaders=ssn) 

result = client.service.getMerchantList()
print result

But the result that I get is: 但是我得到的结果是:

suds.WebFault: Server raised fault: 'Authentication Failed'

Any idea how to authenticate? 任何想法如何进行身份验证? Thank you! 谢谢!

-----------------SOLVED-------------------------------- - - - - - - - - -解决了 - - - - - - - - - - - - - - - -

After more research I found a ruby example, translated it to python, this is the solution: 经过更多研究,我找到了一个ruby示例,将其翻译为python,这是解决方案:

auth = client.factory.create('UserAuthentication')
auth.sApiKey = [api-key]
client.set_options(soapheaders=auth)

Thank you! 谢谢!

After more research I found a ruby example, translated it to python, this is the solution: 经过更多研究,我找到了一个ruby示例,将其翻译为python,这是解决方案:

auth = client.factory.create('UserAuthentication')
auth.sApiKey = [api-key]
client.set_options(soapheaders=auth)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM