TradingView-API icon indicating copy to clipboard operation
TradingView-API copied to clipboard

Credentials error: Wrong or expired sessionid

Open 0xR-Dev opened this issue 3 years ago • 41 comments

did the code still working?

im trying some example there but showing error

"Credentials error: Wrong or expired sessionid"

im have to put correct token id, but still get the error. anyone can help to solve it?

0xR-Dev avatar Apr 14 '23 10:04 0xR-Dev

im try using this code

const TradingView = require("@mathieuc/tradingview");

if (!process.argv[2]) throw Error('Please specify your 'sessionid' cookie');

const client = new TradingView.Client({ token: process.argv[2], });

const chart = new client.Session.Chart(); chart.setMarket('BINANCE:BTCEUR', { timeframe: 'D', });

TradingView.getPrivateIndicators(process.argv[2]).then((indicList) => { indicList.forEach(async (indic) => { const privateIndic = await indic.get(); console.log('Loading indicator', indic.name, '...');

const indicator = new chart.Study(privateIndic);

indicator.onReady(() => {
  console.log('Indicator', indic.name, 'loaded !');
});

indicator.onUpdate(() => {
  console.log('Plot values', indicator.periods);
  console.log('Strategy report', indicator.strategyReport);
});

}); });

output :

$ node indicatorTest.js Loading indicator EMA 20/50/100/200 ... Credentials error: Wrong or expired sessionid

0xR-Dev avatar Apr 14 '23 12:04 0xR-Dev

The same problem

daniil-dn avatar Apr 14 '23 17:04 daniil-dn

It seems that we also need to include the sessionid_sign.

hawooni avatar Apr 14 '23 23:04 hawooni

Same issue here. Seems like TradingView has made a breaking change.

hyjay avatar Apr 14 '23 23:04 hyjay

temporary, if you include "sessionid=${session};sessionid_sign={YOUR_VALUE};" in miscRequests.js line 408 should work.

hawooni avatar Apr 14 '23 23:04 hawooni

temporary, if you include "sessionid=${session};sessionid_sign={YOUR_VALUE};" in miscRequests.js line 408 should work.

+1. It works.

hyjay avatar Apr 14 '23 23:04 hyjay

temporary, if you include "sessionid=${session};sessionid_sign={YOUR_VALUE};" in miscRequests.js line 408 should work.

Thanks its, worked now..

0xR-Dev avatar Apr 15 '23 04:04 0xR-Dev

Also, username/password based login still works well. At least with the most recent version via github


  "dependencies": {
    "@mathieuc/tradingview": "github:Mathieu2301/TradingView-API",
  }

Simply run await TradingView.loginUser(...) and then use the client without passing any arguments.

kyr0 avatar Apr 15 '23 16:04 kyr0

How can I use your method without it disconnecting my browser TradingView? @kyr0

I still get the same error with this code.. @0xR-Dev @hawooni

sign = "v1:j6C5uAzIpQcAfHIUMhyFESRrKWCeO/fv/mt+4qRRPsE="
  async getUser(session, location = 'https://www.tradingview.com/') {
    return new Promise((cb, err) => {
      https.get(location, {
        headers: { cookie: `sessionid=${session};sessionid_sign=${sign}` },

lordbritish888 avatar Apr 17 '23 13:04 lordbritish888

I got the sessionid and the sessionid_sign from the browser on an already logged in instance of TradingView

lordbritish888 avatar Apr 17 '23 13:04 lordbritish888

I got the sessionid and the sessionid_sign from the browser on an already logged in instance of TradingView

If your current browser sessionId and sessionid_sign match, it should work just fine using both.

hawooni avatar Apr 17 '23 13:04 hawooni

@hawooni it still isn't working :/

I even tried this:

const clientTV = new TradingView.Client({ token: process.argv[2], session: process.argv[2], sessionid_sign: "v1:j6C5uAzIpQcAfHIUMhyFESRrKWCeO/fv/mt+4qRRPsE=" });

lordbritish888 avatar Apr 17 '23 14:04 lordbritish888

@Mathieu2301 can you patch this please? or can anyone provide an updated miscRequests.js with corresponding login via token example?

lordbritish888 avatar Apr 17 '23 14:04 lordbritish888

@hawooni it still isn't working :/

I even tried this:

const clientTV = new TradingView.Client({ token: process.argv[2], session: process.argv[2], sessionid_sign: "v1:j6C5uAzIpQcAfHIUMhyFESRrKWCeO/fv/mt+4qRRPsE=" });

Hard code the value sessionid_sign directly as mentioned above as this is just a temporary solution. Or you could try user/password method.

hawooni avatar Apr 17 '23 14:04 hawooni

@hawooni The user/password method disconnects the browser session :/

are you using the vi: part or just the part after for signing?

lordbritish888 avatar Apr 17 '23 14:04 lordbritish888

@hawooni The user/password method disconnects the browser session :/

are you using the vi: part or just the part after for signing?

I have not tried user/password method kyr0 mentioned that it is working.

hawooni avatar Apr 17 '23 14:04 hawooni

@hawooni it works well, just you cannot use TV in your browser while its running and re-logging in on browser disconnects the NodeJS session :/

lordbritish888 avatar Apr 17 '23 14:04 lordbritish888

@0xR-Dev does your sign look like this?

sign = "v1:j6C5uAzIpQcAfHIUMhyFESRrKWCeO/fv/mt+4qRRPsE="

lordbritish888 avatar Apr 17 '23 15:04 lordbritish888

After the log in method was mostly good, I'm now getting this..

Login error: Please confirm that you are not a robot by clicking the captcha box .

lordbritish888 avatar Apr 17 '23 16:04 lordbritish888

temporary, if you include "sessionid=${session};sessionid_sign={YOUR_VALUE};" in miscRequests.js line 408 should work.

I have replaced line 408 to like this but I still encounter the credentials error ?

    headers: { cookie: `sessionid=${session};sessionid_sign={v1:Ms/DU43561uJEfjdkbJPrz1GDBNLrl6YTIpmDY=};` },

amayp1 avatar Apr 17 '23 21:04 amayp1