Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extend google-page-changes with support for dp method #3

Merged
merged 2 commits into from
May 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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