Once a URL has been generated using td_auth_loginURL
, a user
can visit that URL to log into a TD brokerage account, granting the TD app
access to the account. Once the button "Allow" is pressed, the user will be
redirected, potentially to "This site can't be reached". This indicates a
successful log in. The URL of this page contains the Authorization Code.
Paste the entire URL, not just the Authorization Code, into
td_auth_refreshToken. The authorization code will be an extremely long alpha
numeric string starting with 'https'.
The output of td_auth_refreshToken will be a Refresh Token which will be used
to gain access to the TD Brokerage account(s) going forward. The Refresh
Token will be valid for 90 days. Be sure to save the Refresh Token to a safe
location or the manual log in process will be required again. The user can use
td_auth_refreshToken to reset the token before expiration.
The Refresh Token output should be saved in a very safe location, but also
accessible. It will be needed to generate an Access Token using
td_auth_accessToken
, which is used for general account access.
The Access Token expires after 30 minutes.
Note: When running this function interactively (e.g. through RStudio) using
an existing Refresh Token, the function will check the days left until
expiration for the Refresh Token being passed. If the remaining time is
greater than 15 days, the user will be prompted to verify that a new Refresh
Token should be created. The user can select to request a new token, but
there is no net benefit in doing so and TD encourages limiting new token
generation. When running this function in a non-interactive environment (e.g.
CRON Job), if the remaining time until expiration is greater than 15 days,
the default behavior will be to NOT reset the Refresh Token because the new
token will have the same access and capabilities as the existing token.