Skip to main content
Question
FYERS API
Asked a question last year

Can someone please help me how to get access token from auth code with MyApi?

Join FYERS Community to pick others' brains on Trading/Investing

I'm assuming you already have the auth_code so in order to get the access token please execute the following snippet.

from fyers_api.accessToken import SessionModel 

auth_code = "YOUR-AUTHCODE"
app_id = "YOUR-APPID"
app_secret = "YOUR-SECRET-KEY"
grant_type = "authorization_code"

app_session = SessionModel(client_id=app_id, secret_key=app_secret, grant_type=grant_type)

app_session.set_token(auth_code)
response = app_session.generate_token()

print(response["access_token"])