Yes , all of a sudden from yesterday evening the auto login is not happening before that it used to work fine below is my code check if any issue on your side
redirect_uri = “https://trade.fyers.in/api-login/redirect-uri/index.html”
def b64(s):
return base64.b64encode(str(s).encode()).decode()
print(“Generating auth-code link …”)
appSession = fyersModel.SessionModel(
client_id=client_id, redirect_uri=redirect_uri,
response_type="code", state="sample",
secret_key=secret_key, grant_type="authorization_code"
)
print(appSession.generate_authcode())
OTP + PIN flow --------------------------------------------------------------
otp1 = requests.post(
"[https://api-t2.fyers.in/vagator/v2/send_login_otp_v2](https://api-t2.fyers.in/vagator/v2/send_login_otp_v2)",
json={"fy_id": b64(FY_ID), "app_id": "2"}
).json()
if datetime.now().second % 30 > 27:
time.sleep(5)
otp2 = requests.post(
"[https://api-t2.fyers.in/vagator/v2/verify_otp](https://api-t2.fyers.in/vagator/v2/verify_otp)",
json={"request_key": otp1["request_key"], "otp": pyotp.TOTP(TOTP_KEY).now()}
).json()
ses = requests.Session()
pin_res = ses.post(
"[https://api-t2.fyers.in/vagator/v2/verify_pin_v2](https://api-t2.fyers.in/vagator/v2/verify_pin_v2)",
json={"request_key": otp2["request_key"], "identity_type": "pin", "identifier": b64(PIN)}
).json()
ses.headers.update({“authorization”: f"Bearer {pin_res[‘data’][‘access_token’]}"})
token_res = ses.post(
"[https://api-t1.fyers.in/api/v3/token](https://api-t1.fyers.in/api/v3/token)",
json={
"fyers_id": FY_ID, "app_id": client_id[:-4], "redirect_uri": redirect_uri,
"appType": "100", "code_challenge": "", "state": "None", "scope": "",
"nonce": "", "response_type": "code", "create_cookie": True,
}
).json()
auth_code = parse_qs(urlparse(token_res[“Url”]).query)[“auth_code”][0]
session = fyersModel.SessionModel(
client_id=client_id, secret_key=secret_key,
redirect_uri=redirect_uri, response_type="code", grant_type="authorization_code"
)
session.set_token(auth_code)
access_token = session.generate_token()[“access_token”]
print(“FYERS TOKEN:”, access_token)
fyers = fyersModel.FyersModel(client_id=client_id, token=access_token, is_async=False, log_path=os.getcwd())