Using documentation from https://pypi.org/project/td-ameritrade-python-api/
I'm trying to get started with the TD Ameritrade API in Python...
The problem I am having is with authentication of my account which is done via this Url: (note: client_id has been changed b/c it is private)
So everything works:
EXCEPT...
When everything is completed I get this error from FireFox (or Chrome, whatever)
Unable to connect
Firefox can’t establish a connection to the server at 127.0.0.1.
Given the above issue, I search Google for info and did the following:
It does not work at this point.
I have no idea what is going on. Any help would be greatly appreciated.
This is probably one of the few times when getting an error message like you did is actually part of the process to authenticate your account. At the very bottom of the PyPi page for that library he explains that you're supposed to copy and paste the resulting url of the error page you're currently on into your terminal. It was confusing for me aswell and it took me awhile to really understand what's going on so I will explain it as best as I can.
Alex Reed is the guy who made the library TD Ameritrade API and he has an awesome YouTube channel called Sigma Coding. One of his video series guides you through the whole process of directly connecting to the TD Ameritrade API without the use of his API library, and another series about building the library itself.
In this video How to Use the TD Ameritrade API | Part 2 he is demonstrating how to access the API. The link should have a time stamp of 16:36 if not skip ahead to that section and you will see a similar error to what you are experiencing except he is using Chrome, not Firefox so the error is the same but worded differently.
Here's a picture to better explain the rest:
What he does next is copy and paste the current url of the page with the error, which contains the code needed for the next step. The url in the picture starts with https://localhost/test?code=siVrfqPLdQ...
and you can see that the url has code=
following a very long access code that TD Ameritrade needs to generate your access token.
Your url should have a similar structure, don't worry if it doesn't have /test
after localhost, he made a specific folder for the video series. Just copy and paste the whole thing in your terminal where you should have a line that says:
Paste the full redirect url here: