Ask for new 2fa codes when one doesn't work

develop
knotteye 2021-04-25 16:13:59 -05:00
parent 0e34a3b196
commit 26e904b5e9
1 changed files with 13 additions and 8 deletions

View File

@ -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']
response = self.apiRequest('POST', '/oauth/mfa/challenge', { mfa_token = response['mfa_token']
'client_id': self.clientID, while True:
'client_secret': self.clientSecret, mfa_code, code_type = self.totpFunc(self, ctypes)
'mfa_token': response['mfa_token'], response = self.apiRequest('POST', '/oauth/mfa/challenge', {
'challenge_type': code_type, 'client_id': self.clientID,
'code': mfa_code 'client_secret': self.clientSecret,
}) 'mfa_token': mfa_token,
'challenge_type': code_type,
'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']