Closed mgalgs closed 3 years ago
It looks like a localhost callback URL should work for getting an OAuth token: https://github.com/JonCooperWorks/go-tdameritrade/blob/master/examples/webauth/webauth.go
@cwarden nice find! That library looks great... Not sure how they're handling SSL either though... The webauth
example doesn't work for me unless I use an ngrok tunnel... (Issue filed on the parent repo since the fork you linked to doesn't accept issues)
Oh, you're right. You can configure your TD Ameritrade app with an http localhost callback URL and https://auth.tdameritrade.com/auth accepts it, but it changes the protocol to https when redirecting you.
Maybe use simplecert or similar to generate a self-signed cert, and update FinishOAuth2Flow
to get a refresh token by setting access_type
to offline
when exchanging the auth code so dealing with the self-signed cert is a one-time annoyance.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was closed because it has been stalled for 7 days with no activity.
Problem Statement It would be super handy if
ticker
could just sync my positions from the TD Ameritrade API on startup.Proposed Solution I'd propose reaching out to the
account-access/apis-get/accounts-0
endpoint (withfields=positions
) somewhere around here and just slamming them in a[]Lot
to be merged with anylots
from the user's config. I'm slowly working through a PR (dusting off my limitedgo
experience) but wanted to get your thoughts on the approach before I send it off.Initially I'd just expect the user to add a an access token suitable for use with the
Bearer <access token>
Authorization http header in their config as a new yaml option calledtd-access-token
. This means the user has to get set up with the TD Ameritrade API themselves (Getting Started) and then follow the Simple Auth for Local Apps instructions to get their own access token. In the future maybe we could spin up a local webserver on a rando port, but that would require the user get a secure tunnel withngrok
or similar since the TD Ameritrade callback apparently has to be https. (There might be another way around that with local ssl certificates but I haven't looked much into it.)Alternatives I've also thought about automating it externally by operating on my
~/.ticker.yaml
directly but thought something built-in would be cleaner, less moving parts.