Skip to content

Commit

Permalink
Merge pull request #3 from UPowr/google-page-changes
Browse files Browse the repository at this point in the history
extend google-page-changes with support for dp method
  • Loading branch information
mestuddtc authored May 2, 2024
2 parents 9347283 + 6d97fe7 commit 8359d4a
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions aws_google_auth/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,15 @@ def do_login_new(self, first_page):
if "challenge/totp?" in sess.url:
sess = self.handle_totp_new(sess, payload)
elif "challenge/ipp?" in sess.url:
raise NotImplementedError('handle_dp not updated')
raise NotImplementedError('handle_ipp not updated')
elif "challenge/az?" in sess.url:
raise NotImplementedError('handle_dp not updated')
raise NotImplementedError('handle_az not updated')
elif "challenge/sk?" in sess.url:
raise NotImplementedError('handle_dp not updated')
raise NotImplementedError('handle_sk not updated')
elif "challenge/iap?" in sess.url:
raise NotImplementedError('handle_dp not updated')
raise NotImplementedError('handle_iap not updated')
elif "challenge/dp?" in sess.url:
raise NotImplementedError('handle_dp not updated')
sess = self.handle_dp_new(sess)
elif "challenge/ootp/5" in sess.url:
raise NotImplementedError(
'Offline Google App OOTP not implemented')
Expand Down Expand Up @@ -876,6 +876,24 @@ def handle_dp(self, sess):
# Submit Configuration
return self.post(challenge_url, data=payload)

def handle_dp_new(self, sess):
response_page = BeautifulSoup(sess.text, 'html.parser')

input("Check your phone - after you have confirmed response press ENTER to continue.") or None

form = response_page.find('form')
challenge_url = 'https://accounts.google.com' + form.get('action')

payload = {}
for tag in form.find_all('input'):
if tag.get('name') is None:
continue

payload[tag.get('name')] = tag.get('value')

# Submit Configuration
return self.post(challenge_url, data=payload)

def handle_iap(self, sess):
response_page = BeautifulSoup(sess.text, 'html.parser')
challenge_url = sess.url.split("?")[0]
Expand Down

0 comments on commit 8359d4a

Please sign in to comment.