Skip to content

Commit

Permalink
updates csrf token when invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammed78620 committed Jan 15, 2022
1 parent fa3e352 commit 0563b54
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion google/refine/refine.py
Expand Up @@ -97,7 +97,12 @@ def urlopen(self, command, data=None, params=None, project_id=None):
try:
response = urllib2.urlopen(req)
except urllib2.HTTPError as e:
raise Exception('HTTP %d "%s" for %s\n\t%s' % (e.code, e.msg, e.geturl(), data))
if 'Missing or invalid csrf_token parameter' == e.msg:
self.get_csrf_token()
params['csrf_token'] = self.token
response = urllib2.urlopen(req)
else:
raise Exception('HTTP %d "%s" for %s\n\t%s' % (e.code, e.msg, e.geturl(), data))
except urllib2.URLError as e:
raise urllib2.URLError(
'%s for %s. No Refine server reachable/running; ENV set?' %
Expand Down

0 comments on commit 0563b54

Please sign in to comment.