cppclientconnect API: Request Token not working as expected

srirevolver
Hello, I am using CppClientConnect API to connect with my registered client id. I read the documentation and watched the webinar and as they say, I entered the login and got the request token. But after entering the request token, I am getting the error as below:

./example1
login URL: https://kite.zerodha.com/connect/login?v=3&api_key=xxxxxxxxxxxx /// commented out the key
login with this URL and obtain the request token
enter obtained request token: vFTvYjoZqoAcb1zSCh33ul2Rf0Jb0WJo // changed a few characters from the original key, just to show the length of the key obtained
request failed (SSLServerVerification)

1. I tried multiple times with same result
2. I read all the available documentation and only after that I am posting this. (I took the token part from the redirect URL as suggested)

Please do have a look and suggest how I can get this working?

**************
I used the example1.cpp given with the CppClientConnect API. The code that is run is as below:

#include "kitepp.hpp"
#include
#include

namespace kc = kiteconnect;

int main() {
try {
kc::kite Kite(std::getenv("KITE_API_KEY"));
std::string apiSecret = std::getenv("KITE_API_SECRET");

std::cout << "login URL: " << Kite.loginURL() << '\n';
std::cout << "login with this URL and obtain the request token\n";

std::string reqToken;
std::cout << "enter obtained request token: ";
std::cin >> reqToken;

std::string accessToken =
Kite.generateSession(reqToken, apiSecret).tokens.accessToken;
Kite.setAccessToken(accessToken);
std::cout << "access token is " << Kite.getAccessToken() << '\n';

  • srirevolver
    @salim_chisty, Replying your suggestion in another thread https://kite.trade/forum/discussion/comment/51730#Comment_51730,

    I did go through all documentation available and also went through the webinar you suggested. Only then I posted this question above.

    I generated new access token and entered within 1 minute. Still the error comes up as

    "request failed (SSLServerVerification)"

    It seems to be something linked to my account configuration. Please are you able to check? I am stuck at the moment.

    PS: By the way since it is my first ticket on the forum, by mistake a duplicate thread is created. Please when you get time delete that duplicate thread.
  • srirevolver
    I also tried with python scripts available (above is C++), with same result. I believe it is some configuration issue with my account.
  • Nivas
    This is not a Kite Connect error. The message request failed (SSLServerVerification) indicates a local SSL/TLS verification failure on your system while establishing an HTTPS connection. The request does not reach Kite servers.

    This may happen due to one of the following:
    • Missing or outdated CA certificates on the system
    • libcurl/OpenSSL not configured with a valid CA bundle
    • Corporate proxy or firewall performing SSL interception
  • srirevolver
    Hi @Nivas
    1. I re-installed the CA certificates on the system
    2. I re-configured CA bundle linked to OpenSSL
    3. There is no proxy and iptables is allowing all the connections.
    Still the same error keeps coming. FYI, the Python API is giving the below error. Please can you suggest how to enable additional logs from the client API so I can debug further? And are you able to check my API key validity?

    DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.kite.trade:443
    DEBUG:urllib3.connectionpool:https://api.kite.trade:443 "POST /session/token HTTP/1.1" 403 None
    Traceback (most recent call last):
    File "/home/***pykiteconnect/sample.py", line 17, in
    data = kite.generate_session("*************", api_secret="******************")
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/****************/lib/python3.12/site-packages/kiteconnect/connect.py", line 263, in generate_session
    resp = self._post("api.token", params={
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/**************/lib/python3.12/site-packages/kiteconnect/connect.py", line 865, in _post
    return self._request(route, "POST", url_args=url_args, params=params, is_json=is_json, query_params=query_params)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/****************/lib/python3.12/site-packages/kiteconnect/connect.py", line 937, in _request
    raise exp(data["message"], code=r.status_code)
    kiteconnect.exceptions.TokenException: Token is invalid or has expired.

    **** But the token is generated just a minute ago...and NO parallel kite web sessions are running ****
Sign In or Register to comment.