Browse Source

Robustifying getCSRF agains improper encoding detection

Andrej 1 year ago
parent
commit
242ca22f72
1 changed files with 3 additions and 0 deletions
  1. 3 0
      labkeyInterface.py

+ 3 - 0
labkeyInterface.py

@@ -146,6 +146,9 @@ class labkeyInterface:
         except AttributeError:
             print('Failed')
             return None
+        except chardet.UnicodeDecodeError:
+            encoding='ASCII'
+            jsonData=json.loads(response.data.decode(encoding))
 
         self.cookie=response.getheader('Set-Cookie')
         print('User: {} CSRF: {}'.format(jsonData['displayName'],jsonData['CSRF']))