这段代码几乎是从乳齿状 README.md逐字提取的。
它总是会回来
回溯(最近一次调用):文件"C:\Users\matth\GitHub\feed_thing\again.py",第32行,在mastodon.log_in中(文件C:\Users\matth\GitHub\feed_thing\again.py第568行,在log_in name (‘无效用户名、密码或redirect_uris:%s’% e)中) mastodon.Mastodon.MastodonIllegalArgumentError:无效用户名、密码或redirect_uris:(‘乳突API返回错误’,400,“坏请求”,“invalid_grant”)
UPDATE:我从mastodon.social那里得到这个失败,但不是mstdn.social而不是ohai.social。
结果表明,这是由于2个因素造成的,下面的示例代码不是OAUTH2舞蹈。
如何将下面的代码替换为OAUTH2舞蹈?
import os
from mastodon import Mastodon
USERNAME_AS_EMAIL = os.environ["USERNAME_AS_EMAIL"]
PASSWORD = os.environ["PASSWORD"]
APP_NAME = "APP_NAME"
Mastodon.create_app(
APP_NAME,
api_base_url = 'https://mastodon.social',
to_file = 'pytooter_clientcred.secret'
)
mastodon = Mastodon(
client_id = 'pytooter_clientcred.secret',
api_base_url = 'https://mastodon.social'
)
mastodon.log_in(
USERNAME_AS_EMAIL,
PASSWORD,
to_file = 'pytooter_usercred.secret'
)
mastodon = Mastodon(
client_id = 'pytooter_clientcred.secret',
access_token = 'pytooter_usercred.secret',
api_base_url = 'https://mastodon.social'
)发布于 2022-11-30 18:39:20
我找到了部分解决方案。如果在您的帐户上启用了2个因子auth,mastodon.py (截至今天)无法处理登录。如果您禁用2因子auth,那么您可以按预期登录。
对于发现这种情况的人来说,另一个提示是,有时需要删除*.secret文件才能使mastodon.py工作(也就是说,如果您已经更改了服务器名称,但没有更改.secret文件)
https://stackoverflow.com/questions/74631471
复制相似问题