我已经尝试实现 Netsuite 的 OAuth 示例,如下所示:https : //netsuite.custhelp.com/app/answers/detail/a_id/42165。我已将其直接发布在下方,因此如果您不想要,则不必转到该页面。
不幸的是,它不起作用。我知道我有正确的令牌和消费者密钥和秘密,以及正确的帐户 ID。不过,它给了我一个很好的错误:
{"error" : {"code" : "INVALID_LOGIN_ATTEMPT", "message" : "Invalid login attempt."}}
Run Code Online (Sandbox Code Playgroud)
我可以查看我的登录审核,并看到它说签名无效。但是代码本身看起来不错,并且是由 Netsuite 提供的。
我也在 Node.JS 中尝试了一些方法,但没有让它们工作。关于我下一步应该走哪个方向的任何建议?
import oauth2 as oauth
import requests
import time
url = "https://rest.netsuite.com/app/site/hosting/restlet.nl?script=992&deploy=1"
token = oauth.Token(key="080eefeb395df81902e18305540a97b5b3524b251772adf769f06e6f0d9dfde5", secret="451f28d17127a3dd427898c6b75546d30b5bd8c8d7e73e23028c497221196ae2")
consumer = oauth.Consumer(key="504ee7703e1871f22180441563ad9f01f3f18d67ecda580b0fae764ed7c4fd38", secret="b36d202caf62f889fbd8c306e633a5a1105c3767ba8fc15f2c8246c5f11e500c")
http_method = "GET"
realm="ACCT123456"
params = {
'oauth_version': "1.0",
'oauth_nonce': oauth.generate_nonce(),
'oauth_timestamp': str(int(time.time())),
'oauth_token': token.key,
'oauth_consumer_key': consumer.key
}
req = oauth.Request(method=http_method, url=url, parameters=params)
signature_method = oauth.SignatureMethod_HMAC_SHA1()
req.sign_request(signature_method, consumer, token)
header = req.to_header(realm) …Run Code Online (Sandbox Code Playgroud)