From 3404b8788739efb44a34cdcdcb71e35f527c47eb Mon Sep 17 00:00:00 2001 From: Mathieu Colmon Date: Fri, 21 Feb 2025 02:44:42 +0100 Subject: [PATCH] Fix authentication --- src/miscRequests.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/miscRequests.js b/src/miscRequests.js index 4f2bc81..424bf37 100644 --- a/src/miscRequests.js +++ b/src/miscRequests.js @@ -428,10 +428,11 @@ module.exports = { * @returns {Promise} Token */ async getUser(session, signature = '', location = 'https://www.tradingview.com/') { - const { data } = await axios.get(location, { + const { data, headers } = await axios.get(location, { headers: { cookie: genAuthCookies(session, signature), }, + maxRedirects: 0, validateStatus, }); @@ -457,6 +458,10 @@ module.exports = { }; } + if (headers.location !== location) { + return this.getUser(session, signature, headers.location); + } + throw new Error('Wrong or expired sessionid/signature'); },