Skip to content

Commit

Permalink
Fix authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu2301 committed Feb 21, 2025
1 parent cdfe8d7 commit 3404b87
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/miscRequests.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,11 @@ module.exports = {
* @returns {Promise<User>} 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,
});

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

Expand Down

0 comments on commit 3404b87

Please sign in to comment.