Skip to content

nelsongarym/td_auth_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Intended way to use

This is meant to be an easy way to get going with the td ameritrade apis without having to worry about how to call and refresh the tokens. all you have to do is start this server when you want to write your app and then in your code just do a simple GET call to https://localhost:81/data . It will return a json obj that has an "access_token" attribute that you can use for all other calls. Get a new access token before every call you make though if you want to ensure it isnt expired. there is logic in this code writen to handle token expiration and refreshing. The service caches the token in memory so unless it has to refresh at the same time you are calling it should be pretty instant. If you want to force a refresh you can call the api at https://localhost:81/auth/refresh . also the root url (https://localhost:81/) can be used to check the status of the service.

Getting Started

  • Install latest version of NodeJS https://nodejs.org/en/
  • clone the repo
  • go into the index.js folder and change the CLIENT_ID at the top to yours and then go to the run the server steps below

To Run the Server

Generating self signed cert to secure API in dev env

  • Need openssl tool
  • command for mac openssl req -newkey rsa:2048 -nodes -subj '/CN=localhost' -keyout key.pem -x509 -days 365 -out cert.pem

Give your app permission to use TD Ameritrade (one time)

https://auth.tdameritrade.com/auth?response_type=code&redirect_uri={Callback URL}&client_id={Consumer Key}@AMER.OAUTHAP

About

API to handle td ameritrade api token negotiation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published