Unable to Authenticate User – Fyers API Token Issue (401 Error)

Hello Team,

I am facing continuous issues with Fyers API authentication. Even after generating new access tokens using the official get_token_v3.py flow, my API requests fail with the following error:

“code”: -16,

“message”: “Could not authenticate the user”,

“s”: “error”

What I have tried so far:

  1. Generated fresh ACCESS_TOKEN and REFRESH_TOKEN multiple times.

  2. Updated the .env file properly with new tokens.

  3. Verified token with a JWT decoder – payload shows valid values (sub: access_token, iat, exp, etc.).

  4. Tried API endpoints like /v3/profile and /data/history – both return the same 401 authentication error.

  5. Followed documentation instructions carefully, but still unable to authenticate.

Environment:

Python 3.12

Redirect URI: http://127.0.0.1:5000/callback

Client ID: [Your Client ID]

App Type: Trading App

Request:

Kindly help me resolve this issue. Please confirm if there is a mismatch in Client ID/App ID setup or if there is any known problem with token validation at present.

Thanks,

Swapnil Mahajan

Hello @100096293201786711179, one of our team members connected with you earlier. I hope your issue has been resolved. Let me know if you need any further assistance.

Hello Abhi, What was solution I am facing same issue.

Raw Response: 401 {“code”:-16,“message”:“Could not authenticate the user”,“s”:“error”}

{"error":{"code":-16,"message":"Could not authenticate the user","s":"error"}}

Please share.the solution

Environment Python 3.12 using VS Code

Redirect URI: http://127.0.0.1:5006/callback

Client ID: [Your Client ID]