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.

almel
  • 7,178
  • 13
  • 45
  • 58

1 Answers1

4

If you're using the sample code from the Docs.. they are missing 1 piece.

(java)

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

The Documentation sample forgot to mention, you'll need to set the Token Key/Secret on the Request object, before you make the call the get AuthorizeUri.

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

alphaadidas
  • 332
  • 2
  • 6
  • I know this post is a bit old, but, any chance you have a full working example of the code from this page https://developer.etrade.com/ctnt/dev-portal/getContent?contentUri=V0_Code-Tutorial? When I get to AccountListResponse response = account_client.getAccountList(), I see "Invalid access token used" in the log. I am sure this is my lack of understanding how to use OAuth. Any help would be appreciated. – Doo Dah Aug 16 '18 at 16:14
  • 1
    @DooDah I struggled with this a bit but finally figured it out. I made a sample application here: https://github.com/Danieltreiber/Etrade-Sample – Daniel Treiber Oct 10 '18 at 17:55