Skip to content

Instantly share code, notes, and snippets.

@akhan118
Created July 27, 2018 21:01
Show Gist options
  • Select an option

  • Save akhan118/f59bb06799ce16f20fe01933c7775bc5 to your computer and use it in GitHub Desktop.

Select an option

Save akhan118/f59bb06799ce16f20fe01933c7775bc5 to your computer and use it in GitHub Desktop.
Get Access Token
def get_access_token(self):
#Post Access Token Request
headers = { 'Content-Type': 'application/x-www-form-urlencoded' }
data = { 'grant_type': 'refresh_token', 'refresh_token': self.refresh_token,
'client_id': self.client_id, 'redirect_uri': 'http://localhost:8080'}
authReply = requests.post('https://api.tdameritrade.com/v1/oauth2/token', headers=headers, data=data)
return authReply
@mfjv4
Copy link

mfjv4 commented Dec 21, 2018

Greetings AKhan118. Thank you for posting your TDAmeritrade python code. I have a friend who's asked me to write a program to automate his transactions on his TDAmeritrade account based on a variety of rules he has using some technical analysis indicators. Rather than reinvent the wheel (not that I could), I was wondering whether your code above is what is used to obtain the TDA authentication token initially? or do you have to contact a TDA broker to obtain the initial auth token? Thanks in advance for any insight you might share.. m

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment