I'm new to algo trading and trying to autyomate login but getting totp based error.
Here is my code
import pyotp
import time
from fyers_api import fyersModel
from fyers_api import accessToken
from pyotp import TOTP
from selenium import webdriver
from selenium.webdriver.common.by import By
client_id = "ascvwqeq"
secret_key = "ascew"
redirect_uri = "https://trade.fyers.in/api-login/redirect-uri/index.html"
response_type = "code"
state = "sample_state"
grant_type = "authorization_code"
user_name = "asdef"
pin1 = '2'
pin2 = '2'
pin3 = '2'
pin4 = '2'
def generate_auth_code():
session=accessToken.SessionModel(
client_id=client_id,
secret_key=secret_key,
redirect_uri=redirect_uri,
response_type=response_type,
grant_type=grant_type
)
response = session.generate_authcode()
driver = webdriver.Chrome()
driver.get(response)
time.sleep(20)
driver.find_element(By.XPATH,'//*[@id="mobile-code"]').send_keys('99XXXXXXX')
driver.find_element(By.XPATH, '//*[@id="mobileNumberSubmit"]').click()
time.sleep(20)
#t=TOTP("JBSWY3DPEHPK3PXP").now()
#print(t)
totp = pyotp.TOTP('base32secret3232')
t = totp.now()
# OTP verified for current time
if totp.verify(t):
print("YES")
driver.find_element(By.XPATH,'//*[@id="first"]').send_keys(t[0])
driver.find_element(By.XPATH,'//*[@id="second"]').send_keys(t[1])
driver.find_element(By.XPATH,'//*[@id="third"]').send_keys(t[2])
driver.find_element(By.XPATH,'//*[@id="fourth"]').send_keys(t[3])
driver.find_element(By.XPATH,'//*[@id="fifth"]').send_keys(t[4])
driver.find_element(By.XPATH,'//*[@id="sixth"]').send_keys(t[5])
driver.find_element(By.XPATH,'//*[@id="confirmOtpSubmit"]').click()
driver.find_element(By.ID,'//*[@id="first"]').send_keys(pin1)
driver.find_element(By.ID,'//*[@id="second"]').send_keys(pin2)
driver.find_element(By.ID,'//*[@id="third"]').send_keys(pin3)
driver.find_element(By.ID,'//*[@id="fourth"]').send_keys(pin4)
driver.find_element(By.ID,'//*[@id="createPinSubmit"]').click()
generate_auth_code()
but getting the error"You have entered an invalid TOTP. Please make sure you have entered it correctly."
Can anyone please help me out(I'm using jupyter notebook to code)