Error in API Login

Hi,

I use the standard code to log into Fyers API. From yesterday I am facing error.

BASE_URL = “https://api-t2.fyers.in/vagator/v2”

BASE_URL_2 = “https://api.fyers.in/api/v2”

URL_SEND_LOGIN_OTP = BASE_URL + “/send_login_otp”

URL_VERIFY_TOTP = BASE_URL + “/verify_otp”

URL_VERIFY_PIN = BASE_URL + “/verify_pin”

URL_TOKEN = BASE_URL_2 + “/token”

URL_VALIDATE_AUTH_CODE = BASE_URL_2 + “/validate-authcode”

def send_login_otp(fy_id, app_id):

try:

	payload = {

		"fy_id": fy_id,

		"app_id": app_id

	}

	result_string = [requests.post](http://requests.post)(url=URL_SEND_LOGIN_OTP, json=payload)

	if result_string.status_code != 200:

		return [ERROR, result_string.text]

	result = json.loads(result_string.text)

	request_key = result["request_key"]

	return [SUCCESS, request_key]

except Exception as e:

	return [ERROR, e]
FY_ID = row['login_id']  # Your fyers ID

APP_ID_TYPE = "2"  # Keep default as 2, It denotes web login

TOTP_KEY = row['code']  # TOTP secret is generated when we enable 2Factor TOTP from myaccount portal

PIN = row['yob']  # User pin for fyers account

APP_ID = row['api_key'][:-4]  # App ID from myapi dashboard is in the form appId-appType. Example - EGNI8CE27Q-100, In this code EGNI8CE27Q will be APP_ID and 100 will be the APP_TYPE

REDIRECT_URI = row['redirect_uri']  # Redirect url from the app.

APP_TYPE = "100"

APP_ID_HASH = hashlib.sha256((row['api_key']+":"+row['api_secret']).encode()).hexdigest()  # SHA-256 hash of appId-appType:appSecret

send_otp_result = send_login_otp(fy_id=FY_ID, app_id=APP_ID_TYPE)

if send_otp_result[0] != SUCCESS:

	[logging.info](http://logging.info)(f"send_login_otp failure - {send_otp_result[1]}")

	break

########

The output is as follows

2023-11-16 13:04:46,344 - start

2023-11-16 13:04:46,589 - C0 Fyers

2023-11-16 13:04:46,714 - send_login_otp failure -

502 Bad Gateway

502 Bad Gateway


cloudflare

2023-11-16 13:04:46,714 - end

@subhajit_bhar

Hi @arindam_ghosh ,

Are running it locally or on the server?

In my laptop locally. I am in Scotland.

any update? @ZppA1qLXjC I will check what happens on Friday.

@arindam_ghosh , @ZppA1qLXjC

I got similar error yesterday (Thursday, 16th Nov, 2023) while running from cloud. Here id my error message.

verify totp failure -
 
502 Bad Gateway

# 502 Bad Gateway

---

cloudflare

I am not sure why I got this error. Although when I run from local it works!.

Today( Friday, 17th Nov, 2023), I am not getting such error,

Hi @arindam_ghosh @subhajit_bhar ,

We are checking issue , will update once resolved.

Hi @arindam_ghosh ,

Can you please share your Client Id and IP address in my DM

It worked today.

OK thanks for informaing @arindam_ghosh