MCPcopy Index your code
hub / github.com/Mathieu2301/TradingView-API / addUser

Method addUser

src/classes/PinePermManager.js:71–97  ·  view source on GitHub ↗

* Adds an user to the authorized list * @param {string} username User's username * @param {Date} [expiration] Expiration date * @returns {Promise<'ok' | 'exists' | null>}

(username, expiration = null)

Source from the content-addressed store, hash-verified

69 * @returns {Promise<'ok' | 'exists' | null>}
70 */
71 async addUser(username, expiration = null) {
72 try {
73 const { data } = await axios.post(
74 'https://www.tradingview.com/pine_perm/add/',
75 `pine_id=${
76 this.pineId.replace(/;/g, '%3B')
77 }&username_recip=${
78 username
79 }${
80 expiration && expiration instanceof Date
81 ? `&expiration=${expiration.toISOString()}`
82 : ''
83 }`,
84 {
85 headers: {
86 origin: 'https://www.tradingview.com',
87 'Content-Type': 'application/x-www-form-urlencoded',
88 cookie: genAuthCookies(this.sessionId, this.signature),
89 },
90 },
91 );
92
93 return data.status;
94 } catch (e) {
95 throw new Error(e.response.data.detail || 'Wrong credentials or pineId');
96 }
97 }
98
99 /**
100 * Modify an authorization expiration date

Callers 1

PinePermManage.jsFile · 0.80

Calls 1

genAuthCookiesFunction · 0.85

Tested by

no test coverage detected