Search code examples
phpoauthetrade-api

Configuring ETrade PHP API OAuth


I'm trying to set up the ETrade PHP API...

In the sandbox configuration I set my ETWS_APP_KEY and ETWS_APP_SECRET with the keys ETrade Provided.

What do I set for the OAUTH information shown below? I'm confused.. do I leave these blank or where do I obtain these values?

setConst('OAUTH_ACCESS_TOKEN',      '');
setConst('OAUTH_ACCESS_TOKEN_SECRET','');

Solution

  • You have the app tokens, now you need an access token for a user. The process is the same as documented on Auth Documentation

    1. Get Request Token
    2. Validate
    3. Get Access Token
    4. Access API

    Here is one way to get the access token for your sandbox environment.

    1) Download the Etrade SDK for PHP: SDK download

    2) Execute the PHP Command line script in: ./Samples/test_etOAuth.php . You cant open it in the browser since it uses STDIN for menu responses.

    3) type: 1 for "Get Token".

    4) Copy the authorize URL to your browser.

    5) type: n, for not opening the url in a browser off the commandline (unless you run a local php server on your desktop)

    6) Enter the validation code you received in the browser onto the command line when it asks you to: "Please enter verifier code :" .

    7) copy "your final authorized token" from the command line. These are the final pieces you are asking for in your question.

    Now you can access the account / market information through the API.