what i did wrong in my code

my code step by step

  • pip install fyers-apiv3
  • 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)

  • 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.eyJpc3MiOiJhcGkubG9naW4uZnllcnMuaW4iLCJpYXQiOjE3MjcIl0iLCJzdWIiOiJhdXRoX2NvZGUiLCJkaXNwbGF5X25hbWUiOiJZQTE1NzYWRhNmY1MzNmNDNlMTJjN3ODEzOGIyNjRkNTFiMGVlM2E0MFwcF9pZCI6IjZINkhCUjM3VVciLCJ1dWlkIjoiMjIxNGY1NDM1NmY4NDM1NTk3NzZjZGE2ODU0NDk0ZGUiLCJpcEFkZHIiOiIwLjAuMC4wIiwic***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)

–header ‘Content-Type: application/json’ \

–data-raw ‘{“grant_type”: “refresh_token”,“appIdHash”: “df0d5179f181f7c6c0e1b4c2c99eca231ae99b8a515493f7bae3d80d790ece2e”,“refresh_token”: “eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhcGkuZnllcnMuaW4iLCJpYXQiOjE3MjcwNzA5OTksI4iLCJhdF9oYXNoIjoiZ0FBQUFBQm04UU1YbEpBekFpZGc2RzFWMkUyMGk2NlM0WjJvLXh1X1RwVlUtdlgyOHBaeDZsRzlrU1N2ZkF5V19UWk5hWURlMEU5aTVRQnpnQ0NtNFk9IiwiZGlzcGxheV9uYW1lIjoiQU1BTiAiLCJvbXMiOiJLMSIsImhzbV9rZXkiOiIzYWQyY*********sImFwcFR5cGUiOjEwMCwicG9hX2ZsYWciOiJOIn0.vIYPCykdt5ZK7pK6YJDMcgLz4kY0S-vSuPMGh3MEhFw”,“pin”: “4**1”}’

  • 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.

Hey @116446267125478553362

As per the given screenshot you are using the CURL in Python , hence you are facing this .Please copy the CURL and use it in ’ Postman ’ so that you get the right response
https://myapi.fyers.in/docsv3#tag/Authentication-and-Login-Flow-User-Apps/paths/~1Authentication%20&%20Login%20Flow%20-%20User%20Apps/post

hey after paste CURL IN POSTMAN WEBSITE I GOT THIS LINK*. SO NOW WHAT I DO NEXT STEP TO LOGIN API OR DOWNLOAD HISTORICAL DATA -----

*LINK - https://api-t1.fyers.in/api/v3/validate-refresh-token

Hey @116446267125478553362

Please check the documentation given earlier to know the flow of login

After pasting the CURL in postman you can hit the send button with the method set as ‘GET’ , this would give you the right response.

HEY ABHI,

AFTER sending from postman website with get method. i got this error. please explaine me step by step.

error- {
“s”: “error”,
“code”: 500,
“message”: “Invalid Request, please provide valid method”
}


this is my code step by step in jupyter notebook

  • pip install fyers-apiv3
  • 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****2AH”

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)

  • Import the required module from the fyers_apiv3 package

from fyers_apiv3 import fyersModel

Define your Fyers API credentials

client_id = “6H6***UW-100” # Replace with your client ID

secret_key = “CD****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.eyJpc3MiOiJhcGkubG9naW4uZnllcnMuaW4iLCJpYXQiOjE3MjcxODcxMzAsImV4cCI6MTcyNzIxNz**************wbGF5X25hbWUiOiJZQTE1NzY1Iiwib21zIjoiSzEiLCJoc21fa2V5IjoiM2FkMmE1ZWRhNmY1MzNmNDNlMTJjNmRmZTlmMzBjNTY3ODEzOGIyNjRkNTFiMGVlM2E0MzJkYzMiLCJub25jZSI6IiIsImFwcF9pZCI6IjZINkhCUjM3VVciLCJ1dWlkIjoiNGI1NzU5ZWFhZGFkNGMxOWIxOTVmODE2ZjIxMjIyNzQiLCJpcEFkZHIiOiIwLjAuMC4wIiwic2NvcGUiOiIifQ.zdTUQbybaMkg4L-C6Zmr34w3xGGY-c9bYWwuDLcQ5gE”

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)

  • AFTER GETING ACCESS TOKEN , REFRESH TOKEN I EDIT THIS CURL WITH MY DETAILS WITH APPIDHash, refresh token, pin . and paste it into postman website. and Get method then send. i got this error
  • 
    

This is my CURL ----{"grant_type": "refresh_token","appIdHash":"df0d5179f181f7c6c0e1b4c******15493f7bae3d80d790ece2e""refresh_token": "eyJ0eXAiOiJK*********1Njc4MTM4YjI2NGQ1MWIwZWUzYTQzMmRjMyIsImZ5X2lkIjoiWUExNTc2NSIsImFwcFR5cGUiOjEwMCwicG9hX2ZsYWciOiJOIn0.FudOwJPpxLIUxlJJFtgRNnDhFlTQ2rzN40RR1gHSpwo", "pin": "4**1"}
```json
{
    "s": "error",
    "code": 500,
    "message": "Invalid Request, please provide valid method"
}

help me what wrong i did in this process. step by step. ALL MY INFORMATION IN THIS RIGHT I CHECK AGAIN AND AGAIN

Hey @116446267125478553362

Could you please provide your contact details so that we can connect over a call and understand the use case of this and help you accordingly