Skip to content
Snippets Groups Projects
Commit 3731de55 authored by Bryan Tong Minh's avatar Bryan Tong Minh
Browse files

Supply token on login if necessary

parent 993b3467
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,7 @@ Mwclient 0.6.4 is unreleased.
* Bug 2690034: Fix revision iteration
* Fix module conflict with simplejson-1.x by inserting mwclient path at the
beginning of sys.path instead of the end
* Supply token on login if necessary
== Changes in version 0.6.3 ==
* Added domain parameter to login.
......
......@@ -323,13 +323,18 @@ class Site(object):
if self.credentials:
wait_token = self.wait_token()
kwargs = {
'lgname': self.credentials[0],
'lgpassword': self.credentials[1]
}
if self.credentials[2]:
kwargs['lgdomain'] = self.credentials[2]
while True:
if self.credentials[2]:
login = self.api('login', lgname = self.credentials[0], lgpassword = self.credentials[1], lgdomain = self.credentials[2])
else:
login = self.api('login', lgname = self.credentials[0], lgpassword = self.credentials[1])
login = self.api('login', **kwargs)
if login['login']['result'] == 'Success':
break
elif login['login']['result'] == 'NeedToken':
kwargs['lgtoken'] = login['login']['token']
elif login['login']['result'] == 'Throttled':
self.wait(wait_token, login['login'].get('wait', 5))
else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment