I'm using the twitter-api-v2 package and I cant save my access_token
, access_token_secret
and oauth_verifier
. i want to save the oauth_verifier
because i want to create the actual bot in another file.
Here's what I've found
- Using writeFile throws me the error in my catch statement
- Using writeFileSync keeps me stuck on the page, and does not write to the file
- Trying to tweet something works, the tweet is sent in the background, but i stay stuck on the page
client
.login(oauth_verifier)
.then(({ client: loggedClient, accessToken, accessSecret }) => {
let tokens = {
accessToken: accessToken,
accessSecret: accessSecret,
};
fs.writeFile("./tokens.json", JSON.stringify(tokens));
// loggedClient.v2.tweet("hello this is test number: 3"); << this works. i stay stuck
//on the redirect page, but the tweet is sent
})
.catch(() => res.status(403).send("Invalid verifier or access tokens!"));
I was able to save my access_token
and access_token_secret
the first time i ran this code. but I cannot anymore.
I will also add, to clear any confusion, i am not providing a service. This is a bot that i am creating to practice, and i am not providing a servce. if that is relevant.