schwab-api
schwab-api copied to clipboard
invalid_token on get_transaction_history_v2
With code
# %%
from schwab_api import Schwab
import pprint
# Initialize our schwab instance
api = Schwab()
# %%
# Login using playwright
print("Logging into Schwab")
logged_in = api.login(
username=getenv_or_input("SCHWAB_USERNAME"),
password=getenv_or_input("SCHWAB_PASSWORD", input=getpass),
totp_secret=getenv_or_input("SCHWAB_TOTP_SECRET", input=getpass),
lazy=True,
# Get this by generating TOTP at https://itsjafer.com/#/schwab
)
await api._async_login()
# %%
# Get information about a few tickers
quotes = api.quote_v2(["PFE", "AAPL"])
pprint.pprint(quotes)
# %%
# Get information about all accounts holdings
print("Getting account holdings information")
account_info = api.get_account_info()
pprint.pprint(account_info)
print("The following account numbers were found: " + str(account_info.keys()))
# %%
transactions = {account_id: api.get_transaction_history_v2(account_id) for account_id in account_info.keys()}
# %%
pprint.pprint(transactions)
I get the response
(['{"error_description":"5e9cdf15-22f1-126b-7c7c-259f2dbedaaf","error":"invalid_token"}'],
False)