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)
if 'error' in response and response['error'] == 'mfa_required':
if response['supported_challenge_types'] == 'totp' or 'totp' in response['supported_challenge_types']:
mfa_code, code_type = self.totpFunc(self, response['supported_challenge_types'])
response = self.apiRequest('POST', '/oauth/mfa/challenge', {
'client_id': self.clientID,
'client_secret': self.clientSecret,
'mfa_token': response['mfa_token'],
'challenge_type': code_type,
'code': mfa_code
})
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', {
'client_id': self.clientID,
'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:
raise ValueError
self.token = response['access_token']