I found this on reddit last night. Maybe it will help someone to get the API to work.
https://www.reddit.com/r/algotrading/comments/914q22/successful_access_to_td_ameritrade_api/
successful access to TD ameritrade API
Step 1 Register https://developer.tdameritrade.com/
Step 2 Go to my Apps and create an App
step 3 Give a name and user id and set the Callback URL to a http :// localhost and a description
Step 4 get an Authorization code
https://developer.tdameritrade.com/content/simple-auth-local-apps
Step 5 to get the code open a new tab and put this http with your local host and user id
r/https://auth.tdameritrade.com/auth?response_type=code&redirect_uri=use your local host &client_id= use your app user name
Step 6 Authorize the link to your TD trading Account username and password
Step 7 go to the link and it will give you a unable to connect 404 page , but , copy the http part that comes after “code=” in the http address it is a long series of numbers and letters
copy the address to a note pad
Step 8 google URL decode and decode
Step 9 copy the code and URL decode the code and keep this new code
step 10 Get the Access Token here
https://developer.tdameritrade.com/authentication/apis/post/token-0
Step 11 Fill the Access Token information
grant_type: authorization_code
access_type: offline
code = the URL CODE you copied and decoded goes here
client_id = your td dev app user id
redirect_uri = you local host
Step 12 Press send and get the token code will be in the response tab at the bottom
"access_token": " Your token code is here "
Copy all info on a note pad
Step 13 Go to the TD developer quotes API and paste the Token Code in Authorization
https://developer.tdameritrade.com/quotes/apis/get/marketdata/quotes
Symbol = AAPL
Authorization = the token code you requested from Post Access Token
Step 14 Authenticate in the little box bottom left corner with your TD trading account username and password
Step 15 you are now able to get real time data request from TD API