gpt4 book ai didi

python-3.x - NetSuite python TBA 身份验证

转载 作者:行者123 更新时间:2023-12-04 02:53:29 34 4
gpt4 key购买 nike

我对使用 SOAP 进行 NetSuite 调用这一领域不熟悉。因此,我可能完全错误地思考如何解决问题。这是我试图解决的问题:
- 语言:Python+ Zeep
- 我想将我的应用程序从电子邮件传递移动到基于 token 的身份验证。

在 Python 中,我能够为 TokenPassport 生成所有参数。
这是我感到困惑的地方:我在堆栈上查找了一些代码,并注意到人们正在使用 client.service.login() 方法登录。此方法采用通行证而不是 token 通行证对象。
是否有一个单独的方法可以使用 tokenpassport obj 进行登录?,或者我是否需要生成(硬编码)带有参数的 XML,并且这是作为数据在 header 中传递的?

谢谢

最佳答案

希望下面的代码可以帮助刚开始的人。

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})

关于python-3.x - NetSuite python TBA 身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53993401/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com