I'm maintaining a continuous running script, which resets the sandbox on dewiki (the sandbox on dewiki is a bit different to the ones on e.g. enwiki, it's a specialized script, not the reset_sandbox one).
It's been running without problems for several months, but suddenly since 12. February I only get "badtoken: Invalid token" exceptions when trying to save a page. When restarting it runs fine for a while, and then only gets "badtoken: Invalid token" on page.save.
Here is an example from the log
```
2015-02-17 10:43:39 Rahu.py, 182 in reset_sandbox: INFO {lightyellow}17. February 2015, 10:43:39: Reseting Sandbox ...{default}
2015-02-17 10:43:39 login.py, 205 in login: INFO Logging in to wikipedia:de as AsuraBot
2015-02-17 10:43:40 login.py, 223 in login: VERBOSE Should be logged in now
2015-02-17 10:43:40 throttle.py, 247 in wait: INFO Sleeping for 7.0 seconds, 2015-02-17 10:43:40
2015-02-17 10:43:48 api.py, 1314 in submit: VERBOSE API Error: query=
{'action': [u'edit'],
'assert': [u'user'],
'basetimestamp': [Timestamp(2015, 2, 17, 9, 22, 18)],
'bot': [True],
'createonly': [False],
'format': ['json'],
'maxlag': ['5'],
'minor': [False],
'nocreate': [False],
'notminor': [False],
'recreate': [True],
'summary': [u'[[WP:Bots', u'Bot]]: Spielwiese gem\xe4ht (zur\xfcckgesetzt)'],
'text': [u'{{Bitte erst NACH dieser Zeile schreiben! (Begr\xfc\xdfungskasten)}}\n{{subst:Vorlage:Bitte erst NACH dieser Zeile schreiben! (Begr\xfc\xdfungskasten)/Text}}'],
'title': [u'Wikipedia:Spielwiese'],
'token': [u'6c367b3d3ec08fed211b51859359f8d054e263f0+\\']}
2015-02-17 10:43:48 api.py, 1316 in submit: VERBOSE response=
{u'servedby': u'mw1190', u'error': {'help': u'See https://de.wikipedia.org/w/api.php for API usage'}}
2015-02-17 10:43:48 page.py, 1056 in _save: VERBOSE Error saving page [[Wikipedia:Spielwiese]] (badtoken: Invalid token)
Traceback (most recent call last):
File "/shared/pywikipedia/core/pywikibot/page.py", line 1047, in _save
watch=watchval, bot=botflag, **kwargs)
File "/shared/pywikipedia/core/pywikibot/site.py", line 1041, in callee
return fn(self, *args, **kwargs)
File "/shared/pywikipedia/core/pywikibot/site.py", line 4048, in editpage
result = req.submit()
File "/shared/pywikipedia/core/pywikibot/data/api.py", line 1318, in submit
raise APIError(code, info, **result["error"])
APIError: badtoken: Invalid token
2015-02-17 10:43:48 Rahu.py, 195 in reset_sandbox: INFO {lightyellow}Edit to page [[Wikipedia:Spielwiese]] failed:
badtoken: Invalid token while reseting!{default}
2015-02-17 10:43:49 Rahu.py, 182 in reset_sandbox: INFO {lightyellow}17. February 2015, 10:43:49: Reseting Sandbox ...{default}
2015-02-17 10:43:49 login.py, 205 in login: INFO Logging in to wikipedia:de as AsuraBot
2015-02-17 10:43:50 login.py, 223 in login: VERBOSE Should be logged in now
2015-02-17 10:43:50 throttle.py, 247 in wait: INFO Sleeping for 7.5 seconds, 2015-02-17 10:43:50
2015-02-17 10:43:58 api.py, 1314 in submit: VERBOSE API Error: query=
{'action': [u'edit'],
'assert': [u'user'],
'basetimestamp': [Timestamp(2015, 2, 17, 9, 22, 18)],
'bot': [True],
'createonly': [False],
'format': ['json'],
'maxlag': ['5'],
'minor': [False],
'nocreate': [False],
'notminor': [False],
'recreate': [True],
'summary': [u'[[WP:Bots', u'Bot]]: Spielwiese gem\xe4ht (zur\xfcckgesetzt)'],
'text': [u'{{Bitte erst NACH dieser Zeile schreiben! (Begr\xfc\xdfungskasten)}}\n{{subst:Vorlage:Bitte erst NACH dieser Zeile schreiben! (Begr\xfc\xdfungskasten)/Text}}'],
'title': [u'Wikipedia:Spielwiese'],
'token': [u'6c367b3d3ec08fed211b51859359f8d054e263f0+\\']}
2015-02-17 10:43:58 api.py, 1316 in submit: VERBOSE response=
{u'servedby': u'mw1139', u'error': {'help': u'See https://de.wikipedia.org/w/api.php for API usage'}}
2015-02-17 10:43:58 page.py, 1056 in _save: VERBOSE Error saving page [[Wikipedia:Spielwiese]] (badtoken: Invalid token)
Traceback (most recent call last):
File "/shared/pywikipedia/core/pywikibot/page.py", line 1047, in _save
watch=watchval, bot=botflag, **kwargs)
File "/shared/pywikipedia/core/pywikibot/site.py", line 1041, in callee
return fn(self, *args, **kwargs)
File "/shared/pywikipedia/core/pywikibot/site.py", line 4048, in editpage
result = req.submit()
File "/shared/pywikipedia/core/pywikibot/data/api.py", line 1318, in submit
raise APIError(code, info, **result["error"])
APIError: badtoken: Invalid token
2015-02-17 10:43:58 Rahu.py, 195 in reset_sandbox: INFO {lightyellow}Edit to page [[Wikipedia:Spielwiese]] failed:
badtoken: Invalid token while reseting!{default}
2015-02-17 10:44:01 Rahu.py, 182 in reset_sandbox: INFO {lightyellow}17. February 2015, 10:44:01: Reseting Sandbox ...{default}
2015-02-17 10:44:01 login.py, 205 in login: INFO Logging in to wikipedia:de as AsuraBot
2015-02-17 10:44:02 login.py, 223 in login: VERBOSE Should be logged in now
2015-02-17 10:44:03 throttle.py, 247 in wait: INFO Sleeping for 4.9 seconds, 2015-02-17 10:44:03
2015-02-17 10:44:08 api.py, 1314 in submit: VERBOSE API Error: query=
{'action': [u'edit'],
'assert': [u'user'],
'basetimestamp': [Timestamp(2015, 2, 17, 9, 22, 18)],
'bot': [True],
'createonly': [False],
'format': ['json'],
'maxlag': ['5'],
'minor': [False],
'nocreate': [False],
'notminor': [False],
'recreate': [True],
'summary': [u'[[WP:Bots', u'Bot]]: Spielwiese gem\xe4ht (zur\xfcckgesetzt)'],
'text': [u'{{Bitte erst NACH dieser Zeile schreiben! (Begr\xfc\xdfungskasten)}}\n{{subst:Vorlage:Bitte erst NACH dieser Zeile schreiben! (Begr\xfc\xdfungskasten)/Text}}'],
'title': [u'Wikipedia:Spielwiese'],
'token': [u'6c367b3d3ec08fed211b51859359f8d054e263f0+\\']}
2015-02-17 10:44:08 api.py, 1316 in submit: VERBOSE response=
{u'servedby': u'mw1228', u'error': {'help': u'See https://de.wikipedia.org/w/api.php for API usage'}}
2015-02-17 10:44:08 page.py, 1056 in _save: VERBOSE Error saving page [[Wikipedia:Spielwiese]] (badtoken: Invalid token)
Traceback (most recent call last):
File "/shared/pywikipedia/core/pywikibot/page.py", line 1047, in _save
watch=watchval, bot=botflag, **kwargs)
File "/shared/pywikipedia/core/pywikibot/site.py", line 1041, in callee
return fn(self, *args, **kwargs)
File "/shared/pywikipedia/core/pywikibot/site.py", line 4048, in editpage
result = req.submit()
File "/shared/pywikipedia/core/pywikibot/data/api.py", line 1318, in submit
raise APIError(code, info, **result["error"])
APIError: badtoken: Invalid token
```
Why is the token always the same? The relevant part of the script:
```
def reset_sandbox()
site = pywikibot.Site()
site.login()
sandboxPage = pywikibot.Page(site, sandboxTitle)
sandboxPage.get(force=True, get_redirect=True)
sandboxPage.text = sandboxDefault
sandboxPage.save(comment=comment, botflag=botflag, minor=False)
```
I previously used a shared site object, which causes the same errors.