Skip to Content
GET/api/v3/generate-authcode

Generate Auth Code

This API allows you to send a user to the FYERS login page and receive an auth code on your redirect URI.

USE CASE

Start the login for your own FYERS account and receive an auth_code on your redirect_uri.

Details

  • Open this URL in the user's browser (a GET request); the user then logs in with their FYERS credentials.
  • redirect_uri must be the same URL provided at app creation. Example: https://trade.fyers.in/api-login/redirect-uri/index.html.
  • Send a random state. The same value is returned after a successful login, so verify it before using the code.
  • The redirect carries an auth_code, which you exchange for an access token with Validate Auth Code.
  • Use a redirect_uri that is in your control, not a public endpoint such as google.com, because the auth token is sensitive.

Request Attributes

AttributeData TypeDescription
client_idstringThis is the app_id which you have received after creating the app.
Eg: “qwerty-100”
redirect_uristringThis is where the user will be redirected after successful login.
Eg: https://trade.fyers.in/api-login/redirect-uri/index.html
This should be the same as what was provided at the time of app creation
response_typestringThis value must always be “code”
statestringYou send a random value. The same value will be returned after successful login to the redirect uri.
Eg: “abcdefg”

Response Attributes

AttributeData TypeDescription
sstringok / error
codeintThis is the code to identify specific responses
messagestringThis is the message to identify the specific error responses
auth_codestringString value which will be used to generate the access_token
statestringThis value is returned as is from the first request
Last updated on