Ask for new 2fa codes when one doesn't work
parent
0e34a3b196
commit
26e904b5e9
|
@ -86,14 +86,19 @@ class Account():
|
||||||
response = self.apiRequest('POST', '/oauth/token', request_data)
|
response = self.apiRequest('POST', '/oauth/token', request_data)
|
||||||
if 'error' in response and response['error'] == 'mfa_required':
|
if 'error' in response and response['error'] == 'mfa_required':
|
||||||
if response['supported_challenge_types'] == 'totp' or 'totp' in response['supported_challenge_types']:
|
if response['supported_challenge_types'] == 'totp' or 'totp' in response['supported_challenge_types']:
|
||||||
mfa_code, code_type = self.totpFunc(self, response['supported_challenge_types'])
|
ctypes = response['supported_challenge_types']
|
||||||
|
mfa_token = response['mfa_token']
|
||||||
|
while True:
|
||||||
|
mfa_code, code_type = self.totpFunc(self, ctypes)
|
||||||
response = self.apiRequest('POST', '/oauth/mfa/challenge', {
|
response = self.apiRequest('POST', '/oauth/mfa/challenge', {
|
||||||
'client_id': self.clientID,
|
'client_id': self.clientID,
|
||||||
'client_secret': self.clientSecret,
|
'client_secret': self.clientSecret,
|
||||||
'mfa_token': response['mfa_token'],
|
'mfa_token': mfa_token,
|
||||||
'challenge_type': code_type,
|
'challenge_type': code_type,
|
||||||
'code': mfa_code
|
'code': mfa_code
|
||||||
})
|
})
|
||||||
|
if not 'error' in response:
|
||||||
|
break
|
||||||
elif 'error' in response:
|
elif 'error' in response:
|
||||||
raise ValueError
|
raise ValueError
|
||||||
self.token = response['access_token']
|
self.token = response['access_token']
|
||||||
|
|
Loading…
Reference in New Issue