It looks like you're new here. If you want to get involved, click one of these buttons!
export let generateAccessToken = async (req: Request, res: Response) => {
try {
const api_key = process.env.ZERODHA_API_KEY;
const api_secret = process.env.ZERODHA_API_SECRET;
const request_token = req.query.request_token;
const checksumInput = `${api_key}${request_token}${api_secret}`;
const checksum = await Crypto
.createHash('sha256')
.update(checksumInput)
.digest('hex');
const accessTokenResponse = await axios.post('https://api.kite.trade/session/token',
{
"api_key": api_key,
"request_token": request_token,
"checksum": checksum
},
{
headers: {
"X-Kite-Version": 3
}
});
res.send(JSON.stringify(accessTokenResponse));
}
catch (ex) {
res.send('Error ' + ex);
}
}
And the result is always this:
I am not sure , but i think version 3 passes as int instead of string.. I might be wrong too.
"content-type": "application/x-www-form-urlencoded"
too but the result is the sameYou may need to use an additional library as well.