0

我正在尝试创建一个 javascript 应用程序并连接到 Etrade API。有趣的是,我在 Oauth 等更难的事情上取得了成功,并收到了我的访问令牌和秘密,但是当我尝试访问实际数据时,我得到一个“未经授权的访问 - 消费者密钥丢失错误”。相同的代码/工作流程适用于所有前面的步骤,所以我很困惑为什么它在这里不起作用,而 Etrade 的工作人员似乎对提供帮助并不特别感兴趣。

我的代码如下,感谢您的帮助。(这是使用 appcelerator 但我不认为这与问题特别相关)

var step4 = Ti.Network.createHTTPClient();
var step4url = "https://etwssandbox.etrade.com/accounts/sandbox/rest/accountlist?oauth_consumer_key="+consumerKey+"&oauth_token="+accesstoken+"&oauth_nonce="+auth_parameters.oauth_nonce + "&oauth_signature_method=HMAC-SHA1&oauth_timestamp=" + auth_parameters.oauth_timestamp+"&oauth_signature="+authSignature;

step4.setRequestHeader('Authorization', 'OAuth oauth_consumer_key="' + consumerKey + '",oauth_timestamp="'+auth_parameters.oauth_timestamp+'",oauth_nonce="'+auth_parameters.oauth_nonce+'",oauth_signature_method="HMAC-SHA1",oauth_signature="'+authSignature+'",oauth_token="'+accesstoken+'"');

step4.open("GET", step4url);
step4.send();
4

1 回答 1

0

想通了,它与cookie有关。在验证码步骤中设置的 ETRADE Cookie 标头会干扰后续 API 调用。也许这对将来的某人有帮助。

于 2016-03-11T16:42:30.353 回答