Unable to request Auth code

I am using following python to generate TOTP and then generate auth code. Based on clientid, secred id, redirect url, fyers id, pan and secret id before below code... the code generate TOTP correctly. but post it gives error as below. suggest. is there any change in URL.

==================================================

FYERS API TOKEN GENERATOR

==================================================

Please ensure you've configured your credentials in the script.

You need to fill in: client_id, secret_id, fyers_id, pan, and totp_secret

==================================================

✅ Generated TOTP: 23456 (changed for privacy)

Requesting auth code...

❌ HTTP Error: 503

<html>

<head><title>503 Service Temporarily Unavailable</title></head>

<body>

<center><h1>503 Service Temporarily Unavailable</h1></center>

</body>

</html>

--- Code

# Step 1: Generate TOTP

totp = pyotp.TOTP(valid_secret)

otp = totp.now()

print(f"✅ Generated TOTP: {otp}")

# Step 2: Generate Auth Code

login_data = {

"fyers_id": fyers_id,

"password": "", # Leave blank for v3 TOTP flow

"pan": pan,

"app_id": client_id,

"totp": otp

}

print("Requesting auth code...")

login_response = requests.post("https://api.fyers.in/v3/login", json=login_data)

if not login_response.ok:

print(f"❌ HTTP Error: {login_response.status_code}")

print(login_response.text)

sys.exit(1)

res = login_response.json()

if res.get("code") != 200:

print(f"❌ Login failed: {res}")

sys.exit(1)

auth_code = res["data"]["auth_code"]

print("✅ Auth code generated successfully")

# Step 3: Exchange Auth Code for Access Token

token_request = {

"grant_type": "authorization_code",

"app_id": client_id,

"secret_id": secret_id,

"code": auth_code,

"redirect_uri": redirect_uri

}

1 reply