Skip to content

Commit 3404b87

Browse files
committed
Fix authentication
1 parent cdfe8d7 commit 3404b87

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/miscRequests.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,10 +428,11 @@ module.exports = {
428428
* @returns {Promise<User>} Token
429429
*/
430430
async getUser(session, signature = '', location = 'https://www.tradingview.com/') {
431-
const { data } = await axios.get(location, {
431+
const { data, headers } = await axios.get(location, {
432432
headers: {
433433
cookie: genAuthCookies(session, signature),
434434
},
435+
maxRedirects: 0,
435436
validateStatus,
436437
});
437438

@@ -457,6 +458,10 @@ module.exports = {
457458
};
458459
}
459460

461+
if (headers.location !== location) {
462+
return this.getUser(session, signature, headers.location);
463+
}
464+
460465
throw new Error('Wrong or expired sessionid/signature');
461466
},
462467

0 commit comments

Comments
 (0)