what i did wrong in my code

Screenshot (45).png
204.84KB

my code step by step

  1. pip install fyers-apiv3

  2. # Import the required module from the fyers_apiv3 package

    from fyers_apiv3 import fyersModel

    # Replace these values with your actual API credentials

    client_id = "6H6*****UW-100"

    secret_key = "CD****AH"

    redirect_uri = "https://www.google.com/"

    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)

  3. # Import the required module from the fyers_apiv3 package

    from fyers_apiv3 import fyersModel

    # Define your Fyers API credentials

    client_id = "6H****UW-100" # Replace with your client ID

    secret_key = "C****2AH" # Replace with your secret key

    redirect_uri = "https://www.google.com/" # Replace with your redirect URI

    response_type = "code"

    grant_type = "authorization_code"

    # The authorization code received from Fyers after the user grants access

    auth_code = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhcGkubG9naW4uZnllcnMuaW4iLCJpYXQiOjE3Mj*****cIl0iLCJzdWIiOiJhdXRoX2NvZGUiLCJkaXNwbGF5X25hbWUiOiJZQTE1NzY********WRhNmY1MzNmNDNlMTJjN******3ODEzOGIyNjRkNTFiMGVlM2E0M*******FwcF9pZCI6IjZINkhCUjM3VVciLCJ1dWlkIjoiMjIxNGY1NDM1NmY4NDM1NTk3NzZjZGE2ODU0NDk0ZGUiLCJpcEFkZHIiOiIwLjAuMC4wIiwic*******e7dSeCDFPFm14c__AaDDkriu1IBx3Tk"

    # Create a session object to handle the Fyers API authentication and token generation

    session = fyersModel.SessionModel(

    client_id=client_id,

    secret_key=secret_key,

    redirect_uri=redirect_uri,

    response_type=response_type,

    grant_type=grant_type

    )

    # Set the authorization code in the session object

    session.set_token(auth_code)

    # Generate the access token using the authorization code

    response = session.generate_token()

    # Print the response, which should contain the access token and other details

    print(response)

  4. curl --location --request POST 'https://api-t1.fyers.in/api/v3/validate-refresh-token' \

    --header 'Content-Type: application/json' \

    --data-raw '{"grant_type": "refresh_token","appIdHash": "df0d5179f181f7c6c0e1b4c2c99eca231ae99b8a515493f7bae3d80d790ece2e","refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhcGkuZnllcnMuaW4iLCJpYXQiOjE3MjcwNzA5OTksI*******4iLCJhdF9oYXNoIjoiZ0FBQUFBQm04UU1YbEpBekFpZGc2RzFWMkUyMGk2NlM0WjJvLXh1X1RwVlUtdlgyOHB******aeDZsRzlrU1N2ZkF5V19UWk5hWURlMEU5aTVRQnpnQ0NtNFk9IiwiZGlzcGxheV9uYW1lIjoiQU1BTiAiLCJvbXMiOiJLMSIsImhzbV9rZXkiOiIzYWQyY**********sImFwcFR5cGUiOjEwMCwicG9hX2ZsYWciOiJOIn0.vIYPCykdt5ZK7pK6YJDMcgLz4kY0S-vSuPMGh3MEhFw","pin": "4**1"}'

  5. all upper 3 code run successfully. but when i run 4th code of curl then this error accured. please help me. i don't have python knowladge.

6 replies