Page MenuHomePhabricator

Password from cookies is lost when a user changes
Closed, ResolvedPublicFeature

Description

Feature summary:

We can have multiple accounts with pywikibot but if a user is changed, the session access authoization stored by cookies is lost and password is required again. For example

D:\pwb\GIT\core>pwb shell
Welcome to the Pywikibot interactive shell!
>>> s1 = pywikibot.Site(user='Xqtest')
>>> s1.login()
WARNING: No user is logged in on site wikipedia:de
Password for user Xqtest on wikipedia:de (no characters will be shown):
Logging in to wikipedia:de as Xqtest
>>> exit()

D:\pwb\GIT\core>pwb shell
Welcome to the Pywikibot interactive shell!
>>> s1 = pywikibot.Site(user='Xqtest')
>>> s1.login()
>>> s2 = pywikibot.Site(user='Xqtools')
>>> s2.login()
Password for user Xqtools on wikipedia:de (no characters will be shown):
Logging in to wikipedia:de as Xqtools
>>> s1.logged_in()
True
>>> s2.logged_in()
True
>>> exit()

D:\pwb\GIT\core>pwb shell
Welcome to the Pywikibot interactive shell!
>>> s2 = pywikibot.Site(user='Xqtools')
>>> s1 = pywikibot.Site(user='Xqtest')
>>> s2.login()
>>> s1.login()
Password for user Xqtest on wikipedia:de (no characters will be shown): Traceback (most recent call last):

The access authorization should be kept for each account.

Use case(s):
Cookies in pywikibot.lwp are stored for multiple sites but for a single user only. Either find a way to store cookies for multiple sites and users simultaneously or use different files for each user.

Benefits:
Would be great to store access authoization for each acount. This would be simplify running scripts with multiple accounts without having to give the password over and over again.

Event Timeline

Xqt triaged this task as Medium priority.Nov 29 2022, 11:43 AM
Xqt changed the task status from Open to In Progress.Nov 29 2022, 4:04 PM
Xqt claimed this task.

Change 861895 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] [IMPR] Create a cookie file for each account

https://gerrit.wikimedia.org/r/861895

Behaviour after this change:

D:\pwb\GIT\core>pwb shell
Welcome to the Pywikibot interactive shell!
>>> s1 = pywikibot.Site(user='Xqtest')
>>> s2 = pywikibot.Site(user='Xqtools')
>>> s2.login()
WARNING: No user is logged in on site wikipedia:de
Password for user Xqtools on wikipedia:de (no characters will be shown):
Logging in to wikipedia:de as Xqtools
>>> s1.login()
Password for user Xqtest on wikipedia:de (no characters will be shown):
Logging in to wikipedia:de as Xqtest
>>> exit()

D:\pwb\GIT\core>pwb shell
Welcome to the Pywikibot interactive shell!
>>> s1 = pywikibot.Site(user='Xqtest')
>>> s2 = pywikibot.Site(user='Xqtools')
>>> s1.login()
>>> s2.login()
>>>

Change 861895 merged by jenkins-bot:

[pywikibot/core@master] [IMPR] Create a cookie file for each account

https://gerrit.wikimedia.org/r/861895