Twitter 机器人:在没有三足 OAuth 流程的情况下获取另一个帐户的访问令牌?

Twitter Bot: Get access token for another account without 3-legged OAuth flow?

我控制着三个 Twitter 帐户:一个是我的主帐户,另外两个应该通过机器人自动 post 发布内容。我创建了机器人逻辑并将其添加到 Twitter 的开发工具中,我可以轻松地将其用于 post 我的主帐户。

现在我需要为我的两个辅助帐户添加访问令牌。我的问题是 - 最简单的方法是什么。

据我所知,Twitter 只支持一种方法:3-legged OAuth flow。它并不太复杂,但在我看来需要设置一个带有回调 url 的模拟网站,考虑到我只需要生成两个 api 令牌,这似乎太多了。我错过了什么吗?

你没有遗漏什么。这样做的原因是强制用户打开他们信任的浏览器并看到他们在 https://twitter.com/,这样他们就可以相信这是一个安全的地方来输入他们的密码。

有一些替代方法可以通过命令行工具为 OAuth 1.0A 生成访问令牌和访问令牌机密,这些工具允许您使用“PIN-based”OAuth 流程。

一个例子是 Twitter 自己的 twurl tool for API testing, which requires you to also have Ruby installed. This will let you authenticate a user account (it still pops open a window onto twitter.com to have you do the authentication) and stores them into the ~/.twurlrc file in your home directory. There is also tw-oob-oauth-cli,它是一个独立的应用程序,可以做同样的事情。