junhoyeo / threads-api

Unofficial, Reverse-Engineered Node.js/TypeScript client for Meta's Threads. Web UI Included.
https://threads.junho.io
MIT License
1.58k stars 134 forks source link

Are logins cached across code reruns? [question] #237

Closed ishaanbuildsthings closed 11 months ago

ishaanbuildsthings commented 11 months ago

Thanks for this library,

currently, I am logging in and making a post like this:

const main = async () => {
  const threadsAPI = new ThreadsAPI({
    username: process.env.user,
    password: process.env.pass,
  });

  await threadsAPI.publish({
    text: '🤖 Hello World',
  });
};

main();

To my understanding, the way this works is:

1) When I create a threadsAPI object, I pass the user and pass parameters. 2) When I call a route on the instance of my object, for the first time, a token is automatically generated based on the earlier arguments. The sessions is validated and internally stored. 3) Future api route calls to my instance re-use this generated session, as to not log in each time.

Is this correct? So if I call .publish, then later .repost, the .repost call will reuse the session that was initially created?

And are sessions preserved across code-runs, or is the internally cached session deleted, meaning each time I rerun my code, exactly one login attempt is retriggered?

Thanks for anyone who can provide help!

junhoyeo commented 11 months ago

Is this correct? So if I call .publish, then later .repost, the .repost call will reuse the session that was initially created?

Correct :)