Fresh request_token rejected with TokenException – Personal API application

raaja2026
Hello Kite Connect Team,

I am trying to establish my first Python connection using a Personal Kite Connect API application.

My authentication process is:

1. Generate login URL using the official KiteConnect Python SDK.
2. Log in successfully to Zerodha.
3. Receive a fresh request_token with status=success.
4. Immediately exchange the request_token using kite.generate_session().
5. Receive the following error:

HTTP 403
TokenException: Token is invalid or has expired.

I have verified the following:

- API Key and API Secret belong to the same application.
- Application is active.
- Zerodha Client ID matches the application configuration.
- Redirect URL is correctly configured.
- A fresh request_token is generated for every attempt.
- Authentication was tested using both the original project and a separate standalone Python program.
- The official KiteConnect Python SDK is being used.

Could you please investigate whether there is an application-side or account-side restriction preventing session generation?

Please let me know if you need any additional information to investigate this issue.

Thank you.
  • salim_chisty
    The error message indicates that your request token might have expired. A request token, however, is valid for only a few minutes and can be used just once. To resolve this, you need to fetch a new request token and exchange it for an access token.
    Please note that the exchange mandates that traders log in manually at least once a day, and we do not recommend automating the login process.

    Here are the key details:
    - Access tokens are flushed daily at 7:30 AM, and new tokens are generated at 7:35 AM.
    - Ensure you generate the access token after 7:35 AM on the same trading day. The token will remain valid throughout the day unless you log out.

    Additionally, please follow the login flow as outlined in the Kite Connect API documentation. For further guidance, you can refer to this webinar.
Sign In or Register to comment.