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

MediaWiki::Bot fails to log in #77

Closed
dertuxmalwieder opened this issue Dec 8, 2015 · 29 comments
Closed

MediaWiki::Bot fails to log in #77

dertuxmalwieder opened this issue Dec 8, 2015 · 29 comments

Comments

@dertuxmalwieder
Copy link

A few weeks ago, MediaWiki::Bot suddenly stopped to be able to log in.

Here's what I try:

my $wikibot = MediaWiki::Bot->new(
  {
    protocol    => 'https',
    host        => 'de.wikipedia.org',
    path        => 'w',
    operator    => 'MyWikipediaNickname',
    login_data  => {
        username => "RechercheBot",
        password => $botpassword
    },
    debug       => 2
  }
);

Well:

Testing if logged in: we are (my IP), and we should be RechercheBot at /usr/local/libdata/perl5/site_perl/MediaWiki/Bot.pm line 2051.
Couldn't log in with supplied settings at ./recherchebot.pl line 41.

Line 41 is the one starting with my $wikibot.

Manually logging in as RechercheBot (which is a valid, not restricted account) with the supplied settings, however, works well. Do you have a clue?

@doherty
Copy link
Member

doherty commented Dec 9, 2015

When you say "manually logging in" do you mean calling the login method
directly, or logging in using your web browser?

Offhand, I don't know what the issue is. t/02-login.t and t/04-edit.t both
currently pass, which suggest that logging in does work.

On Tue, Dec 8, 2015 at 1:35 PM, Cthulhux notifications@github.com wrote:

A few weeks ago, MediaWiki::Bot suddenly stopped to be able to log in.

Here's what I try:

my $wikibot = MediaWiki::Bot->new(
{
protocol => 'https',
host => 'de.wikipedia.org',
path => 'w',
operator => 'MyWikipediaNickname',
login_data => {
username => "RechercheBot",
password => $botpassword
},
debug => 2
}
);

Well:

Testing if logged in: we are (my IP), and we should be RechercheBot at /usr/local/libdata/perl5/site_perl/MediaWiki/Bot.pm line 2051.
Couldn't log in with supplied settings at ./recherchebot.pl line 41.

Line 41 is the one starting with my $wikibot.

Manually logging in as RechercheBot
http://de.wikipedia.org/wiki/RechercheBot with the supplied settings,
however, works well. Do you have a clue?


Reply to this email directly or view it on GitHub
#77.

@dertuxmalwieder
Copy link
Author

Manually is over my web browser, yes. I'm confused.

@dertuxmalwieder
Copy link
Author

Can I somehow help you track down the problem?

@ghost
Copy link

ghost commented Feb 19, 2016

MediaWiki software changed login procedures. My bot has been dead ever since the change.

See https://lists.wikimedia.org/pipermail/wikitech-l/2016-January/084501.html

@doherty
Copy link
Member

doherty commented Feb 19, 2016

I'm now spending zero time on non-maintainer tasks. Please feel free to fix
this and send a pull request. I'm happy to do code review, merges, and
releases, but I'm not doing development work on this project any longer.

On Fri, Feb 19, 2016 at 11:08 AM, bgwhite notifications@github.com wrote:

MediaWiki software changed login procedures. My bot has been dead ever
since the change.

See
https://lists.wikimedia.org/pipermail/wikitech-l/2016-January/084501.html


Reply to this email directly or view it on GitHub
#77 (comment)
.

@dertuxmalwieder
Copy link
Author

That's bad news. :(

@bgwhite Do you have some time for that?

@ghost
Copy link

ghost commented Feb 19, 2016

I do have time. More importantly, I haven't a clue about cookie jars and
LWP::UserAgent. Time to teach an old dog a new trick.

Bryan

On Fri, Feb 19, 2016 at 3:28 PM, Cthulhux notifications@github.com wrote:

That's bad news. :(

@bgwhite https://github.com/bgwhite Do you have some time for that?


Reply to this email directly or view it on GitHub
#77 (comment)
.

@dertuxmalwieder
Copy link
Author

LWP::UserAgent is greatly documented (although, if I had the chance, I'd switch over to Mojolicious; it's quite easier to use IMO). I can't help with cookie jars though; too many languages at a time ... but I'd gladly help where I can.

@ghost
Copy link

ghost commented Jun 11, 2016

I'm facing the same problem... :(

About this issue as @doherty said: "[...]I'm not doing development work on this project any longer.[...]". No one will submit pull request? If no, can anybody suggest another library that is actively maintained?

@dertuxmalwieder
Copy link
Author

I guess there is none. So the only chance is to fork this and fix the issue.

@doherty
Copy link
Member

doherty commented Jun 11, 2016

If you're going to write a patch, just submit it here. I'm perfectly happy to accept patches and do releases.

@ghost
Copy link

ghost commented Jun 26, 2016

I'm trying to help but I'm not getting some things... (let me known if there is a forum that we can talk about this module)

I'm starting to learn Perl but I could see that your code is based on MediaWiki::API, and I don't known why but the basic login sub works fine.

Could you list please the features your login has that the other don't?

Brad Jorsch (Anomie) said:

"== For bots ==
You shouldn't notice any changes due to SessionManager, but do make sure
your code is handling cookies normally instead of using the deprecated
return values from action=login to construct cookies manually
"

I just don't see in the code where is the "manual handling" (its not handled automatically by LWP module?)...

@wp-seth
Copy link
Member

wp-seth commented Jun 26, 2016

I still don't get the problem. I'm using MediaWiki::Bot v5.005006 (with MediaWiki::API v0.39 and LWP:UserAgent v6.05) at wmlabs without any login trouble at de.wikipedia.org. Which version do you use?

@dertuxmalwieder
Copy link
Author

I can't log in on de.wikipedia.org with the newest Perl modules.

@wp-seth
Copy link
Member

wp-seth commented Jun 26, 2016

are you able to login if you use the versions I mentioned?

@dertuxmalwieder
Copy link
Author

No success with MediaWiki::Bot v5.005006 and MediaWiki::API v0.39. Sadly, LWP::UserAgent v6.05 is 404 everywhere, so I'm stuck with the newest CPAN build.

@jlick
Copy link

jlick commented Jun 29, 2016

MediaWiki 1.27 was recently released to the general public. According to the API documents, the login API has changed in this release: https://www.mediawiki.org/wiki/API:Login#How_to_log_in

I have a bot which maintains parts of the snpedia.com wiki. It was just upgraded to MediaWiki 1.27. Since then my bots have been unable to login. Functions which do not require authentication continue to work correctly.

The code which no longer works is:

$bot=MediaWiki::Bot->new({
host => 'bots.snpedia.com',
path => '',
debug => 1,
protocol => 'https',
operator => 'Jlick',
});

$bot->login({
username => $username,
password => $password,
}) || die "Login failed.";

The errors are:

Error code 2: 500 Internal Server Error : error occurred when accessing https://bots.snpedia.com/api.php after 6 attempt(s) at /Desktop/DNA/bin/snpediapop.pl line 102.
Error code 2: 500 Internal Server Error : error occurred when accessing https://bots.snpedia.com/api.php after 6 attempt(s) at /Desktop/DNA/bin/snpediapop.pl line 102.
Error code 2: 500 Internal Server Error : error occurred when accessing https://bots.snpedia.com/api.php after 6 attempt(s) at /Desktop/DNA/bin/snpediapop.pl line 102.
Login failed. at /Desktop/DNA/bin/snpediapop.pl line 102.

The relevant modules are up to date as per what is in CPAN:

cpan[2]> install MediaWiki::API
MediaWiki::API is up to date (0.41).

cpan[3]> install MediaWiki::Bot
MediaWiki::Bot is up to date (5.006002).

cpan[4]> install LWP:UserAgent
LWP::UserAgent is up to date (6.15).

As this release also triggered end of support for MediaWiki 1.25, you may see a larger than usual number of people upgrading to the new version.

@ghost
Copy link

ghost commented Jun 29, 2016

As of 1.27, the login action should only be used in combination with bot passwords, and clientlogin should be used by interactive applications. Login#How_to_log_in

I tested this new feature called "bot passwords" (just login your account and create a bot password here) and seems its working except that _is_loggedin is not working right. With my new account (username Guiwp@Wik) it says:

Testing if logged in: we are Guiwp, and we should be Guiwp@Wik at /home/guilherme/perl5/lib/perl5/MediaWiki/Bot.pm line 2051.

Guiwp != Guiwp@Wik

@jlick
Copy link

jlick commented Jun 29, 2016

Thanks, guiwp,

You solved my problem, or at least set me on the right path.

The Special:BotPasswords page seems to be specific to wikipedia foundation sites.

From: http://permalink.gmane.org/gmane.science.linguistics.wikipedia.technical/85415

"If you need to continue using the existing action=login, ... go to Special:BotPasswords, set [a bot password] up, and then use new bot-password username and password to login as you've always done (no code changes, just update your bot's configuration)."

But Special:BotPasswords didn't work on the private wiki I use, and it goes on to explain:

"For bots that run on third-party wikis, Bot Passwords are in core and are enabled by default."

This is about as clear as mud. I logged in on the web as my bot and poked around preferences for a bit, and got nowhere trying to find some place to set a bot password.

Then on a whim I decided to change my bot's regular login password. Suddenly my bot script could log in again. Changing the password accomplished whatever magic was required.

So the complete solution is:

On wikipedia foundation sites, go to the Special:BotPasswords page.
On private wikis, log into your bot account and change the password.

Edited to add: There seem to still be some issues. My bot stops working after a few transactions with "Error code 2: 500 Internal Server Error : error occurred when accessing https://bots.snpedia.com/api.php after 6 attempt(s)" errors, but at least this fixes logins.

ETA2: The above errors were due to a server error. After the server problem was fixed, the bot is running again with no errors.

@dertuxmalwieder
Copy link
Author

Hmm - so I gave my bot a bot password and changed the password to the one the particular page told me - still the same problem :(

@jlick
Copy link

jlick commented Jun 29, 2016

Have you tried instead of setting username and password in login_data to use $wikibot->login as in my example?

@dertuxmalwieder
Copy link
Author

That leaves me with "Login failed.". :-(

@doherty
Copy link
Member

doherty commented Jul 7, 2016

Should be fixed by 884f07d

@doherty doherty closed this as completed Jul 7, 2016
@dertuxmalwieder
Copy link
Author

Hmm, I still get "Login failed. at ./recherchebot.pl line 52". Here's my code (line 52 ff):

$wikibot->login({
  username => $botusername,
  password => $botpassword,
}) || die "Login failed.";

$botusername is RechercheBot, the $botpassword is the generated password from the MediaWiki. Any hints?

@doherty
Copy link
Member

doherty commented Jul 10, 2016

When you created the bot password, you gave it a name. You should login
with the combined identifier "RechercheBot@name_of_bot_passwd" which was
displayed on the same page that showed you the generated bot password.
Otherwise, MediaWiki doesn't know to check that your using the bot
password, and instead checks against the regular password -- but you're not
allowed to use that to login.
On Jul 10, 2016 2:02 PM, "Cthulhux" notifications@github.com wrote:

Hmm, I still get "Login failed. at ./recherchebot.pl line 52". Here's my
code (line 52 ff):

$wikibot->login({
username => $botusername,
password => $botpassword,
}) || die "Login failed.";

$botusername is RechercheBot, the $botpassword is the generated password
from the MediaWiki. Any hints?


You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
#77 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAZQPNO_P9nM7iMs3_YTh8RmgTGGOvKiks5qUV3PgaJpZM4GxYAE
.

@dertuxmalwieder
Copy link
Author

Good point, thanks. Corrected it, but I still get Login failed with 'RechercheBot@RechercheBot'...

@ghost
Copy link

ghost commented Jul 10, 2016

Here I don't see any problem, it's working right. Maybe you mistyped something.

@dertuxmalwieder
Copy link
Author

Ah, yes - indeed. My "read from a password file" function didn't work as expected. Thank you, it works now!

@doherty
Copy link
Member

doherty commented Jul 10, 2016

Glad to hear it
On Jul 10, 2016 3:36 PM, "Cthulhux" notifications@github.com wrote:

Ah, yes - indeed. My "read from a password file" function didn't work as
expected. Thank you, it works now!


You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
#77 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAZQPO7T6GF5ns9CuTZSVhlJp9vWRVDQks5qUXPXgaJpZM4GxYAE
.

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

4 participants