Hello,

In one of my scripts, I'm editing a few pages and one of them requires sysop privileges. Before OAuth, I was able to logout, then login as sysop and .save() the page (https://gist.github.com/alkamid/639abbb05ff8e0d2842d0c9dbda1e2d0#file-addlang-py-L175). Now I'm trying to implement the same with OAuth. Saving the protected page works fine, but later in the script, when saving another unprotected page (L190), I get the following error:

Traceback (most recent call last):
  File "/home/adam/wikt/pywikibot/core/pywikibot/page.py", line 1219, in _save
    watch=watch, bot=botflag, **kwargs)
  File "/home/adam/wikt/pywikibot/core/pywikibot/site.py", line 1325, in callee
    self.login(False)
  File "/home/adam/wikt/pywikibot/core/pywikibot/site.py", line 2077, in login
    'right': self._username[sysop]})
pywikibot.exceptions.NoUsername: Logged in on wiktionary:pl via OAuth as Alkamid, but expect as AlkamidBot

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "addLang.py", line 197, in <module>
    main()
  File "addLang.py", line 190, in main
    page8.save(summary="Dodanie języka %s" % zjezyka)
  File "/home/adam/wikt/pywikibot/core/pywikibot/tools/__init__.py", line 1447, in wrapper
    return obj(*__args, **__kw)
  File "/home/adam/wikt/pywikibot/core/pywikibot/page.py", line 1208, in save
    cc=apply_cosmetic_changes, quiet=quiet, **kwargs)
  File "/home/adam/wikt/pywikibot/core/pywikibot/page.py", line 1234, in _save
    raise pywikibot.OtherPageSaveError(self, err)
pywikibot.exceptions.OtherPageSaveError: Edit to page [[Moduł:statystyka/dane]] failed:
Logged in on wiktionary:pl via OAuth as Alkamid, but expect as AlkamidBot
<class 'pywikibot.exceptions.OtherPageSaveError'>
CRITICAL: Closing network session.


How to do this properly? My user-config.py:

usernames['wiktionary']['pl'] = u'AlkamidBot'
sysopnames['wiktionary']['pl'] = u'Alkamid'
usernames['commons']['commons'] = 'Alkamid'

authenticate['pl.wiktionary.org'] = ('a', 'b', 'c', 'd') #credentials deleted
authenticate['pl.wiktionary.org'] = ('e', 'f, 'g', 'h') #credentials deleted

Best wishes
Alkamid