Page MenuHomePhabricator

"pywikibot.exceptions.Error: API write action attempted without userinfo" despite being logged in
Closed, InvalidPublic

Description

When submitting an API call through pywikibot.data.api.Request to do action=wbsetlabel on Commons, the API request is never sent, and pywikibot displays an error message "pywikibot.exceptions.Error: API write action attempted without userinfo".

This happens even if the request immediately follows a login (using an account bot password) via pywikibot.data.api.LoginManager. There does not seem to be a way to pass the userinfo into the request function.

Example code is at https://bitbucket.org/mikepeel/wikicode/src/master/commons_captions_copy.py - the task I am trying to code up copies the description from an image to a Structured Data on Commons caption.

Event Timeline

Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald TranscriptJan 30 2019, 8:47 PM
Xqt triaged this task as High priority.Jan 31 2019, 12:27 AM

Just guessing here, but is there some magic code in the framework that "knows" to do special things when the wiki is Wikidata but doesn't know to do it on Commons?

Mike_Peel closed this task as Resolved.Feb 4 2019, 8:30 PM
Mike_Peel claimed this task.

Aah, I found the problem. I was using the LoginManager class in pywikibot to log in, but I actually needed to use the site class to log in. So, it now works! This edit was by the code that's now on bitbucket:
https://commons.wikimedia.org/w/index.php?title=File:Sala_S%C3%A3o_Paulo_2018_07.jpg&diff=prev&oldid=337738484

(It also didn't work on Wikidata ... I should have double-checked that before, sorry!)

JJMC89 changed the task status from Resolved to Invalid.Feb 5 2019, 2:15 AM