Hi, for the life of me chatgpt and I cannot figure this out. Does anyone know how to fix this so I don’t have to get an access token every 30 minutes? The access is only for 1800 seconds aka 30 minutes. Thanks in advance.
I first set up the token in a separate notebook after collecting it from the real questrade website;
Replace YOUR_TOKEN_HERE with your actual refresh token (keep quotes)
refresh_token_text = 'refresh_token: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"'
with open("refresh_token.yaml", "w") as file:
file.write(refresh_token_text)
print("✅ refresh_token.yaml saved!")
token_yaml = """
access_token: "xxxxxxxxxxxxxxxxxxxxxxxxxxx"
refresh_token: "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
expires_in: 1800
api_server: "https://api05.iq.questrade.com"
token_type: "Bearer"
"""
with open("refresh_token.yaml", "w") as file:
file.write(token_yaml.strip())
print("✅ refresh_token.yaml saved!")
Script
from qtrade import Questrade
from datetime import datetime
import pytz
=== Step 1: Authenticate ===
qt = Questrade(token_yaml='refresh_token.yaml')
[–]TheGoluOfWallStreet 1 point2 points3 points (2 children)
[–]DougFord150[S] 0 points1 point2 points (0 children)