diff --git a/pkg/provider/googleapps/googleapps.go b/pkg/provider/googleapps/googleapps.go index 8409465c0..36a99f953 100644 --- a/pkg/provider/googleapps/googleapps.go +++ b/pkg/provider/googleapps/googleapps.go @@ -63,7 +63,14 @@ func (kc *Client) Authenticate(loginDetails *creds.LoginDetails) (string, error) // Post email address w/o password, then Get the password-input page passwordURL, passwordForm, err := kc.loadLoginPage(authURL+"?hl=en&loc=US", loginDetails.URL+"&hl=en&loc=US", authForm) if err != nil { - return "", errors.Wrap(err, "error loading login page") + //if failed, try with "identifier" + authForm.Set("Email", "") // Clear previous key + authForm.Set("identifier", loginDetails.Username) + passwordURL, passwordForm, err = kc.loadLoginPage(authURL+"?hl=en&loc=US", loginDetails.URL+"&hl=en&loc=US", authForm) + + if err != nil { + return "", errors.Wrap(err, "error loading login page") + } } logger.Debugf("loginURL: %s", passwordURL) @@ -311,11 +318,13 @@ func (kc *Client) loadChallengePage(submitURL string, referer string, authForm u secondFactorHeader := "This extra step shows it’s really you trying to sign in" secondFactorHeader2 := "This extra step shows that it’s really you trying to sign in" + secondFactorHeader3 := "2-Step Verification" secondFactorHeaderJp := "2 段階認証プロセス" // have we been asked for 2-Step Verification if extractNodeText(doc, "h2", secondFactorHeader) != "" || extractNodeText(doc, "h2", secondFactorHeader2) != "" || + extractNodeText(doc, "h1", secondFactorHeader3) != "" || extractNodeText(doc, "h1", secondFactorHeaderJp) != "" { responseForm, secondActionURL, err := extractInputsByFormID(doc, "challenge") @@ -326,7 +335,7 @@ func (kc *Client) loadChallengePage(submitURL string, referer string, authForm u logger.Debugf("secondActionURL: %s", secondActionURL) switch { - case strings.Contains(secondActionURL, "challenge/totp/"): // handle TOTP challenge + case strings.Contains(secondActionURL, "challenge/totp"): // handle TOTP challenge var token = loginDetails.MFAToken if token == "" { @@ -337,7 +346,7 @@ func (kc *Client) loadChallengePage(submitURL string, referer string, authForm u responseForm.Set("TrustDevice", "on") // Don't ask again on this computer return kc.loadResponsePage(secondActionURL, submitURL, responseForm) - case strings.Contains(secondActionURL, "challenge/ipp/"): // handle SMS challenge + 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