试图保存凭据时,卡在Twitter重定向页面上
我正在使用Twitter-API-V2软件包,我无法保存我的access_token
,access_token_secret
和oauth_verifier
。我想保存oauth_verifier
,因为我想在另一个文件中创建实际机器人。
这是我发现使用writefile的内容,
- 捕获语句中给我带来了错误
- 使用writefilesync的
- 在 背景,但是i 在页面上保持卡住
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!"));
,我能够保存我的access_token
和access_token_secret
我第一次运行此代码。但是我不能了。
我还将补充说,为了清除任何混乱,我没有提供服务。这是我要练习的机器人,我没有提供服务。如果那是相关的。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的问题已经解决。
事实证明,问题是我没有向Twitter发送成功回应。
我只需要在我的
中发送200个状态响应。
my issue has been resolved.
Turns out, the problem was that i was not sending a success response to twitter.
I just needed to send a 200 status response in my
.then()
where i write to my json file.