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'); },