tka*_*ara 5 netsuite python-3.x suitetalk
我对使用 SOAP 进行 NetSuite 调用这一领域还不熟悉。因此,我对如何解决问题的思考可能完全错误。这是我想要解决的问题: - 语言:Python+ Zeep - 我想将我的应用程序从电子邮件传递转移到基于令牌的身份验证。
在 Python 中,我能够生成 TokenPassport 的所有参数。这是我感到困惑的地方:我在堆栈上查找了一些代码,发现人们正在使用 client.service.login() 方法来登录。此方法采用护照而不是 tokenpassport 对象。是否有一个单独的方法可以使用 tokenpassport obj 进行登录?或者我是否需要使用参数生成(硬编码)一个 XML,并将其作为数据传入标头?
谢谢你
希望下面的代码对刚开始的人有所帮助。
base = '&'.join([nsAccountID, consumerKey, token, Nonce, currentTime])
key = '&'.join([consumerSecret, tokenSecret])
digest = hmac.new(str.encode(key), msg=str.encode(base), digestmod=hashlib.sha256).digest()
signature = base64.b64encode(digest).decode()
tokenPassport = client.get_type('ns0:TokenPassport')
PassportSignature = client.get_type('ns0:TokenPassportSignature')
tokenPassportSignature = PassportSignature(signature, "HMAC-SHA256" )
clientPass = tokenPassport(account=nsAccountId, consumerKey = consumerKey, token= token, nonce= Nonce, timestamp=currentTime, signature=tokenPassportSignature)
search = client.get_type('ns5:ItemSearchBasic')
searchCriteriaComplex = client.get_type('ns0:SearchStringField')
searchCriteria = searchCriteriaComplex(searchValue= "Test Display Name - tax", operator="is")
searchItem = search(displayName = searchCriteria)
testRes = client.service.search(searchRecord= searchItem, _soapheaders={"tokenPassport": clientPass})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2102 次 |
| 最近记录: |