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
I got response 400 meaning the request is a bad request
response: <Response [400]>
Traceback (most recent call last):
File "/Users/user1/temp/v2/test8.py", line 4, in <module>
tos_client = TOSClient('my-app-consumer-key', '/Users/user1/temp/v2/project/tokens.json')
File "/Users/user1/temp/v2/project/server/toolbox/TOSClient.py", line 23, in __init__
td_credentials = TdCredentials(
File "/Users/user1/env/lib/python3.9/site-packages/td/credentials.py", line 62, in __init__
self.from_credential_file(file_path=credential_file)
File "/Users/user1/env/lib/python3.9/site-packages/td/credentials.py", line 377, in from_credential_file
self.from_token_dict(token_dict=token_dict)
File "/Users/user1/env/lib/python3.9/site-packages/td/credentials.py", line 248, in from_token_dict
self.validate_token()
File "/Users/user1/env/lib/python3.9/site-packages/td/credentials.py", line 580, in validate_token
token_dict = self.grab_access_token()
File "/Users/user1/env/lib/python3.9/site-packages/td/credentials.py", line 560, in grab_access_token
raise requests.HTTPError()
requests.exceptions.HTTPError
I installed this library using pip install btw. Is there any known issue?
this below method in credentials.py throws the exception above:
def grab_access_token(self) -> dict:
"""Refreshes the current access token.
This takes a valid refresh token and refreshes
an expired access token. This is different from
exchanging a code for an access token.
### Returns
----
dict:
The dictionary contain all the token
info.
"""
# build the parameters of our request
data = {
'client_id': self.client_id,
'grant_type': 'refresh_token',
'access_type': 'offline',
'refresh_token': self.refresh_token
}
# Make the request.
response = requests.post(
url="https://api.tdameritrade.com/v1/oauth2/token",
headers={
'Content-Type': 'application/x-www-form-urlencoded'
},
data=data
)
if response.ok:
return response.json()
print('data: ', data)
print('response: ', response)
raise requests.HTTPError()
The text was updated successfully, but these errors were encountered:
I put some logging statements in the
credentials.py
file to see what's going on:Access Token Expired, refreshing access token...
the
data
below comes from my td_credentials.json file, which is posted to TD API to getaccess_token
I got response 400 meaning the request is a bad request
response: <Response [400]>
I installed this library using
pip install
btw. Is there any known issue?this below method in
credentials.py
throws the exception above:The text was updated successfully, but these errors were encountered: