Unable to generate auth code

Hello Team Fyers! Recently I have started my algo trading journey with your Fyers API and I have tried a code for generating the auth code but it didn't work. It was generating the URL but after clicking that I didn't get the auth code instead it was keeps on redirecting to the login page with client id or mobile number. Even after i have logged in, it was again redirecting to the login page again and again. Please let me know if anything can be done with this situation. Thank you.

Here's the code:

from fyers_apiv3 import fyersModel

# Replace these values with your actual API credentials
client_id = "XXXXX" 
secret_key = "XXXX"
redirect_uri = "https://trade.fyers.in/api-login/redirect-uri/index.html"
response_type = "code"  
state = "sample_state"

# Create a session model with the provided credentials
session = fyersModel.SessionModel(
    client_id=client_id,
    secret_key=secret_key,
    redirect_uri=redirect_uri,
    response_type=response_type
)

# Generate the auth code using the session model
response = session.generate_authcode()

# Print the auth code received in the response
print(response)
2 replies