I'm trying to use Kite connect using C#. I am able to get request_token but unable to go further. I'm facing an issue when I try to get access_token from the authentication process. It's showing me 403 forbidden error. please help me to resolve this, thanks in advance.
I tried with your given inputs, I'm getting correct checksum as you mentioned above. But still its giving 403 Forbidden. I'm not able to connect with Kite. Plz elaborate.
Hi All, I faced the same issue with Java. My solution for this issue is adding all request parameters to URL string directly. I am not sure why i get 403 if i set request properties through API call..Below is my URL.
can anybody please share the c# code for connecting to kite.. i am unable to get access code.. it shows {"status": "error", "message": "Route not found", "error_type": "GeneralException"}
any code for proper connection and to get live price will be really helpful i hope someone had figured out the problem ?
plz suggest me whether it is correct or not?
//checksum calculation
SHA256Managed crypt = new SHA256Managed();
StringBuilder hash = new StringBuilder();
//here token is request_token which I'm getting after login process,
byte[] temp = Encoding.UTF8.GetBytes(ApiKey + token + ApiSecretKey);
byte[] crypto = crypt.ComputeHash(temp);
string checksum = string.Empty;
foreach (byte x in crypto)
{
checksum += String.Format("{0:x2}", x);
}
I tried with your given inputs, I'm getting correct checksum as you mentioned above. But still its giving 403 Forbidden. I'm not able to connect with Kite. Plz elaborate.
Waiting for your reply.
My solution for this issue is adding all request parameters to URL string directly.
I am not sure why i get 403 if i set request properties through API call..Below is my URL.
String sha256hex = sha256String(api_key+request_token+secret_key);
URL url = new URL("https://api.kite.trade/session/token?api_key=zrvn5zt7yybwbg0z&request_token="+request_token+"&checksum="+sha256hex);
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.connect();
i am unable to get access code..
it shows
{"status": "error", "message": "Route not found", "error_type": "GeneralException"}
any code for proper connection and to get live price will be really helpful
i hope someone had figured out the problem ?
conn.setRequestMethod("POST");
USE REST SHARP FOR MAKING THE GET POST PUT DEL REQ
whis is same as tejashree
private static string Sha256(string password)
{
var crypt = new SHA256Managed();
var hash = new StringBuilder();
if (password != null)
{
byte[] crypto = crypt.ComputeHash(Encoding.UTF8.GetBytes(password), 0,
Encoding.UTF8.GetByteCount(password));
foreach (byte theByte in crypto)
{
hash.Append(theByte.ToString("x2"));
}
}
return hash.ToString();
}
password
argument. It has to beapi_key + request_token + secret