M
hello,
i have the same issue,
code use working 4 days ago,
i generated the token again and used that to call historical api, but that gave the invalid token error
load_dotenv()
conn = http.client.HTTPSConnection(
"apiconnect.angelbroking.com"
)
conn = http.client.HTTPSConnection("apiconnect.angelbroking.com")
current_time = str(get_current_time())
payload={
"exchange": "NSE",
"symboltoken": "6071",
"interval": "ONE_MINUTE",
"fromdate": "2024-02-08 09:00",
"todate": "2024-02-11 09:00"
}
headers = {
'X-PrivateKey': os.getenv('API_KEY'),
'Accept': 'application/json',
'X-SourceID': 'WEB',
'X-ClientLocalIP': os.getenv('CLIENT_LOCAL_IP'),
'X-ClientPublicIP': os.getenv('CLIENT_PUBLIC_IP'),
'X-MACAddress': os.getenv('MAC_ADDRESS'),
'X-UserType': 'USER',
'Authorization': os.getenv('JWT_TOKEN'),
'Accept': 'application/json',
'X-SourceID': 'WEB',
'Content-Type': 'application/json'
}
conn.request("POST", "/rest/secure/angelbroking/historical/v1/getCandleData", json.dumps(payload), headers)
res = conn.getresponse()
data = res.read().decode("utf-8")
the below code is used to refresh jwt token
obj=SmartConnect(api_key="something")
data = obj.generateSession(data_from_db[0],data_from_db[1],generate_totp())
refreshToken= data['data']['refreshToken']
jwtToken = data['data']['jwtToken']
here generate_otp() give the returns topt using pytop function.