Skip to content

Commit

Permalink
Handle extra "Send text message" challenge page
Browse files Browse the repository at this point in the history
It seems some times google will present an extra "Send text message"
challenge page that requires the user to click on the button to actually
get text message sent and present the code input in the next page.
  • Loading branch information
edwardrf committed Nov 2, 2023
1 parent 4ac5dca commit e6524df
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pkg/provider/googleapps/googleapps.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,26 @@ func (kc *Client) loadChallengePage(submitURL string, referer string, authForm u
return kc.loadResponsePage(secondActionURL, submitURL, responseForm)
case strings.Contains(secondActionURL, "challenge/ipp/"): // handle SMS challenge

if extractNodeText(doc, "button", "Send text message") != "" {
responseForm.Set("SendMethod", "SMS") // extractInputsByFormID does not extract the name and value from <button> tag that is the form submit
doc, err = kc.loadResponsePage(secondActionURL, submitURL, responseForm)
if err != nil {
return nil, errors.Wrap(err, "failed to post sms request form")
}
doc.Url, err = url.Parse(submitURL)
if err != nil {
return nil, errors.Wrap(err, "failed to define URL for html doc")
}

submitURL = secondActionURL
responseForm, secondActionURL, err = extractInputsByFormID(doc, "challenge")
if err != nil {
return nil, errors.Wrap(err, "unable to extract challenge form")
}

logger.Debugf("After sms request secondActionURL: %s", secondActionURL)
}

var token = prompter.StringRequired("Enter SMS token: G-")

responseForm.Set("Pin", token)
Expand Down

0 comments on commit e6524df

Please sign in to comment.