2

I have successively obtained a request token, and am now using it in conjunction with my consumer key to create the following request

https://us.etrade.com/e/etws/authorize?key=2fc*******c323d6&token=IIrs6BsIrGQ********duC60GAmLq8

where the asterisks have been substituted for my consumer key and request token. I give this as an argument to getAuthorizeURL This returns an ETWSException and output in the terminal reading

ERROR OAuthClientImpl - Mandatory parameters missing

I have the two required arguments for the getAuthorizeURL method, and I am sure they are formatted correctly. Can anyone tell me what is going wrong here?

Also, if it helps to know, calling the getAuthorizeURL causes my default browser to open and brings me to the address that I entered above, but it returns a 404 error.

4

1 回答 1

4

如果您使用文档中的示例代码.. 他们缺少 1 件。

(爪哇)

client = OAuthClientImpl.getInstance(); // Instantiate IOAUthClient 
    request = new ClientRequest(); // Instantiate ClientRequest 
    request.setEnv(Environment.SANDBOX); // Use sandbox environment 

    request.setConsumerKey(oauth_consumer_key); //Set consumer key 
    request.setConsumerSecret(oauth_consumer_secret); // Set consumer secret 
    token= client.getRequestToken(request); // Get request-token object

    oauth_request_token = token.getToken(); // Get token string 
    oauth_request_token_secret = token.getSecret(); // Get token secret 

    request.setToken(oauth_request_token);
    request.setTokenSecret(oauth_request_token_secret);

    String authorizeURL = null; 
    authorizeURL = client.getAuthorizeUrl(request);

    URI uri = new URI(authorizeURL);

    Desktop desktop = Desktop.getDesktop(); 
    desktop.browse(uri);

文档示例忘了提及,在调用 get AuthorizeUri 之前,您需要在请求对象上设置令牌密钥/秘密。

request.setToken(oauth_request_token); request.setTokenSecret(oauth_request_token_secret);

于 2014-03-03T04:33:01.497 回答