update csrf token in urlopen_json
This commit is contained in:
parent
0563b54fc6
commit
16541c522e
|
@ -118,6 +118,10 @@ class RefineServer(object):
|
||||||
"""Open a Refine URL, optionally POST data, and return parsed JSON."""
|
"""Open a Refine URL, optionally POST data, and return parsed JSON."""
|
||||||
response = json.loads(self.urlopen(*args, **kwargs).read())
|
response = json.loads(self.urlopen(*args, **kwargs).read())
|
||||||
if 'code' in response and response['code'] not in ('ok', 'pending'):
|
if 'code' in response and response['code'] not in ('ok', 'pending'):
|
||||||
|
if 'Missing or invalid csrf_token parameter' == response['message']:
|
||||||
|
self.get_csrf_token()
|
||||||
|
response = json.loads(self.urlopen(*args, **kwargs).read())
|
||||||
|
return response
|
||||||
error_message = ('server ' + response['code'] + ': ' +
|
error_message = ('server ' + response['code'] + ': ' +
|
||||||
response.get('message', response.get('stack', response)))
|
response.get('message', response.get('stack', response)))
|
||||||
raise Exception(error_message)
|
raise Exception(error_message)
|
||||||
|
|
Loading…
Reference in New Issue