To use the TD Ameritrade API, both a TD Brokerage account and a registered
developer app are required. The developer app functions as a middle layer
between the brokerage account and the API. A developer app should be
registered on the TD Ameritrade
Developer site. Once logged in to the developer site, use My Apps to
register an application. An App will have a Consumer Key provided by TD that
functions as an API key. The Consumer Key is auto generated and can be found
under My Apps > Keys. The user must also create a Callback URL. The Callback
URL can be anything. The example below assumes the Callback URL is
https://myTDapp.
This function will use these two inputs to generate a URL where the user can
log in to their standard TD Ameritrade Brokerage Account and grant the
application access to the brokerage account, enabling the API. The
Authorization Code generated at the end of the log in process will feed into
td_auth_refreshToken. For questions, please reference the
TD
Ameritrade Authentication FAQ or see the examples in the rameritrade readme.
If the callback URL uses punctuation, numbers, or an IP (e.g. 127.0.0.0.1),
the output of this function may not work. Please reference the TD
documentation to create the appropriate URL.