You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A simple CLI wrapper around my tdameritradeclient library. You will need to set the token in an environment variable called `TDAUTHTOKEN`. You can go on [developer.tdameritrade.com](http://developer.tdameritrade.com) to see how to manually create a valid token.
3
+
A simple CLI wrapper around my tdameritradeclient library. For help enter `tdacli --help`. This will give you access to help and further subcommands.
4
4
5
-
For help enter `tdacli --help`. This will give you access to help and further subcommands.
6
-
7
-
Current subcommands are: quote, history, optionchain, userprincipals, account.
5
+
Current subcommands are: quote, history, optionchain, userprincipals, account, auth, refresh, weblink. See below for description on output of `tdaci --help` in the CLI Commands section
8
6
7
+
Environmental Variable Requirements:
8
+
-`TDAUTHTOKEN` on subcommands: account, history, optionchain, quote, userprincipals
9
+
-`TDREFRESHTOKEN` on subcommands: refresh
10
+
-`TDCODE` on subcommand: auth
11
+
- No Env Variable on subcommand: weblink
9
12
10
13
## Example
11
14
12
-
an example usage piped into jq running on linux
13
-
15
+
an example usage piped into jq running on linux. Assumes `TDAUTHTOKEN` env variable holds valid token.
@@ -34,11 +36,61 @@ an example usage piped into jq running on linux
34
36
}
35
37
```
36
38
37
-
## CLI commands
39
+
## Authorization from scratch
40
+
41
+
### 1) Fetch code using weblink
42
+
Use the `weblink` subcommand along with registered app on developer.tdameritrade.com to get an authorization link. When you register an app you will have a `consumer_key` (referred through out as clientid) and a `redirect_uri`. I recommend using a redirecturi that is your localhost (`https://127.0.0.1:8080/`). This way you can copy the returned code directly from the query bar in the browser. The below Consumer Key is only an example.
Visit this link and authorize your access directly with TDameritrade. You will receive the code in the query bar. Only copy the encoded string after `code=`. Assign this to the environment variable `TDCODE`.
51
+
52
+
53
+
54
+
### 2) Use code to retrieve token and refresh_token
55
+
56
+
From step 1 above with `TDCODE` env variable assigned.
Assign the Refresh token to TDREFRESHTOKEN and the Token to TDAUTHTOKEN. You can go ahead and run any of the other subcommands with TDAUTHTOKEN set.
65
+
66
+
A refresh token lasts for 90 days and can be used to get a valid token to access tdameritrade API. The token is only valid for 30 min before expiring. Reuse the same or new refresh token to renew.
0 commit comments