Skip to content

Commit

Permalink
Handle error case for no MFA methods (#203)
Browse files Browse the repository at this point in the history
Handle error case for no MFA methods
  • Loading branch information
cwilko authored Mar 28, 2023
1 parent 70f66a0 commit 4fc678e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions arlo.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,14 @@ def LoginMFA(self, username, password, google_credential_file):
headers=headers,
raw=True
)
email_factor_id = next(i for i in factors_body['data']['items'] if i['factorType'] == 'EMAIL' and i['factorRole'] == "PRIMARY")['factorId']
if email_factor_id is None:
email_factor_id = next(i for i in factors_body['data']['items'] if i['factorType'] == 'EMAIL' and i['factorRole'] == "SECONDARY")['factorId']
email_factor = next((i for i in factors_body['data']['items'] if i['factorType'] == 'EMAIL' and i['factorRole'] == "PRIMARY"), None)
if email_factor is None:
email_factor = next((i for i in factors_body['data']['items'] if i['factorType'] == 'EMAIL' and i['factorRole'] == "SECONDARY"), None)

if email_factor is None:
raise Exception('No EMAIL MFA method registered with the account.')

email_factor_id = email_factor['factorId']

# Start factor auth
start_auth_body = self.request.post(
Expand Down

0 comments on commit 4fc678e

Please sign in to comment.