Idirect-Tech / Breeze-JS-SDK

The official Python client library for the ICICI Securities trading APIs
7 stars 6 forks source link

Getting error `Could not authenticate credentials. Please check token and keys` in Breeze JS sample code demo.js #12

Open vivegi opened 1 year ago

vivegi commented 1 year ago

I am running the demo.js given in the example.

I have generated app_key, secret_key and session_token as per the documented procedure.

When I run the demo.js code (I have renamed the file as algotrade.js in my machine), I get the following error.

> node --trace-warnings .\algotrade.js

(node:11496) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
    at getAllowUnauthorized (node:internal/options:58:13)
    at Object.connect (node:_tls_wrap:1605:29)
    at Agent.createConnection (node:https:150:22)
    at Agent.createSocket (node:_http_agent:350:26)
    at Agent.addRequest (node:_http_agent:297:10)
    at new ClientRequest (node:_http_client:326:16)
    at Object.request (node:https:360:10)
    at RedirectableRequest._performRequest (.\node_modules\follow-redirects\index.js:284:24)
    at new RedirectableRequest (.\node_modules\follow-redirects\index.js:66:8)
    at Object.request (.\node_modules\follow-redirects\index.js:523:14)
Could not authenticate credentials. Please check token and keys

After I set

process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 1;

I don't get the warning, but I still get the error:

Could not authenticate credentials. Please check token and keys

I have tried the following two variations:

In both instances, I get the error.

Unsure what the issue is and how to proceed.

Environment: I am running node v18.6.0 on MS Windows Version 22H2 (OS Build 22621.1413.

sudhakarsi commented 10 months ago

I am getting same error using python api.

Below both executions are done using same session key

C:\Users\Sudhakar>python ICICILOG.py Traceback (most recent call last): File "C:\Users\Sudhakar\AppData\Local\Programs\Python\Python311\Lib\site-packages\breeze_connect\breeze_connect.py", line 743, in api_util raise Exception(except_message.AUTHENICATION_EXCEPTION.value) Exception: Could not authenticate credentials. Please check token and keys

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\Sudhakar\ICICILOG.py", line 16, in breeze.generate_session(api_secret=SecretKey, File "C:\Users\Sudhakar\AppData\Local\Programs\Python\Python311\Lib\site-packages\breeze_connect\breeze_connect.py", line 778, in generate_session self.api_util() File "C:\Users\Sudhakar\AppData\Local\Programs\Python\Python311\Lib\site-packages\breeze_connect\breeze_connect.py", line 745, in api_util raise Exception(except_message.AUTHENICATION_EXCEPTION.value) Exception: Could not authenticate credentials. Please check token and keys

C:\Users\Sudhakar>python ICICILOG.py Traceback (most recent call last): File "C:\Users\Sudhakar\AppData\Local\Programs\Python\Python311\Lib\site-packages\breeze_connect\breeze_connect.py", line 743, in api_util raise Exception(except_message.AUTHENICATION_EXCEPTION.value) Exception: Could not authenticate credentials. Please check token and keys

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\Sudhakar\ICICILOG.py", line 16, in breeze.generate_session(api_secret=SecretKey, File "C:\Users\Sudhakar\AppData\Local\Programs\Python\Python311\Lib\site-packages\breeze_connect\breeze_connect.py", line 778, in generate_session self.api_util() File "C:\Users\Sudhakar\AppData\Local\Programs\Python\Python311\Lib\site-packages\breeze_connect\breeze_connect.py", line 745, in api_util raise Exception(except_message.AUTHENICATION_EXCEPTION.value) Exception: Could not authenticate credentials. Please check token and keys

Idirect-Tech commented 10 months ago

Dear Sir,

Please mail the code without credential at breezeapi@icicisecurities.com.

sudhakarsi commented 10 months ago

Just let us know when your servers are ready. Same code runs and then fails to run. So no code needed in this case.

smtlab commented 10 months ago

Any updates on this? getting same error.

import { BreezeConnect } from "breezeconnect"

export async function connect() {

  const appKey = "--"
  const appSecret = "--"
  const breeze = new BreezeConnect({ appKey })

  await breeze.generateSession(appSecret, "session-key")

}

Error

Uncaught (in promise) Could not authenticate credentials. Please check token and keys

Same code works in python

breeze = BreezeConnect(api_key=BREEZE_CONNECT["API_KEY"])

# Generate Session
breeze.generate_session(api_secret=BREEZE_CONNECT["API_SECRET"],
                        session_token=session_key)
vishnut2003 commented 4 months ago

Hi, iam getting the same error. can you tell me what was the solution you get

vishnut2003 commented 4 months ago

const breeze = new BreezeConnect({ "appKey": "api_key" }) breeze.generateSession({ "secretKey": "secret_key", "sessionToken": "session_key" }) .then((res) => { console.log('success') }) .catch((err) => { console.log(err) })

this is my node.js code

vishnut2003 commented 4 months ago

and iam getting Could not authenticate credentials. Please check token and keys