GenerateNU / Algo

Fullstack application for the Algo project
6 stars 0 forks source link

ETrade OAuth Endpoints/Table #12

Closed jakobphilippe closed 7 months ago

jakobphilippe commented 8 months ago

Description

OAuth Flow implementation

How Has This Been Tested?

  1. Add these keys to the .env file.

    export OAUTH_KEY="OAuth Key Here" export OAUTH_SECRET="OAuth Secret Here"

  2. Create oauth keys by creating an ETrade brokerage account (no funding necessary) and pressing the button at the bottom of this page: https://developer.etrade.com/getting-started/developer-guides.
  3. Uncomment the AutoMigrations in the main.go file and start the server, verifying that the oauths_table is created.
  4. Using Postman or curl, call the GET /redirect endpoint, and verify that a redirect_url is returned.
  5. If you are using your own sandbox oauth key and secret, go to the redirect URL and log in. Once you receive the verifier token, save it.
  6. Using Postman or curl, call the POST /verify endpoint with the JSON body

    { "verifier": "Verifier Token Here" }

  7. Observe the oauths_table and verify a new row filled with tokens.

Note that until authentication is setup, I've hardcoded the user ID that the tokens are generated for, so make sure there is at least one user in the users table.

Checklist

leoRysing commented 8 months ago

Good stuff but we'll have to make sure that after this gets merged people update their go dependencies, continuing to look through the MR

leoRysing commented 8 months ago

For the env variable does it not work in the top level env file we already create? If possible this simplifies down having to juggle multiple env files

leoRysing commented 7 months ago

functionality is looking good! Going to do a second pass in a bit through the actual code. My one thing is it may be good to get the callback url version of this, so that we can auto hit the verify and close the page possibly, depends how this gets integrated on the FE