Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support login via bot password #35

Open
lucaswerkmeister opened this issue Feb 24, 2019 · 1 comment
Open

Support login via bot password #35

lucaswerkmeister opened this issue Feb 24, 2019 · 1 comment

Comments

@lucaswerkmeister
Copy link
Contributor

Currently, mwapi.Session supports login with credentials via action=clientlogin, which only supports the user’s real password (and may require an interactive flow, continuing the login in another step). It would be nice to also support bot passwords – by automatically detecting them in login() (username contains “@”), by adding a new method for action=login instead of action=clientlogin, or at least by documenting the following workaround:

lgtoken = session.get(action='query',
                      meta='tokens',
                      type='login')['query']['tokens']['logintoken']
session.post(action='login',
             lgname=bot_username,
             lgpassword=bot_password,
             lgtoken=lgtoken)
@lucaswerkmeister
Copy link
Contributor Author

lucaswerkmeister commented Mar 30, 2023

Note on this workaround: the login API doesn’t return a standard error when login fails, so this call will appear to “succeed” (i.e., it won’t throw an mwapi.errors.APIError) even if the login didn’t actually work. You’ll want to check that the response’s .login.result == 'Success'. If you use assert='user' on subsequent requests, then that should at least prevent you from leaking your IP address. (Cf. lucaswerkmeister/m3api-botpassword#1.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant