From 213bdb01d3353844b4316712cbde64c257346347 Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Mon, 31 Aug 2026 10:42:55 -0700 Subject: [PATCH] messagix/bloks: investigate google redirect url --- pkg/messagix/bloks/selenium.go | 37 ++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/pkg/messagix/bloks/selenium.go b/pkg/messagix/bloks/selenium.go index 700a36c1..43e4f96d 100644 --- a/pkg/messagix/bloks/selenium.go +++ b/pkg/messagix/bloks/selenium.go @@ -1978,12 +1978,24 @@ func (b *Browser) DoLoginStep(ctx context.Context, userInput map[string]string) } case StateOAuthPage: - b.DisplayedURL = "" - - err = b.CurrentPage. + oauthButton := b.CurrentPage. FindDescendant(FilterByAttribute("bk.data.TextSpan", "text", "Verify with Google")). - FindContainingButton(). - TapButton(ctx, b.CurrentPage.Interpreter) + FindContainingButton() + if oauthButton == nil { + return nil, fmt.Errorf("couldn't find verify with Google button") + } + + oauthRedirectURL := userInput["oauth_token"] + if oauthRedirectURL != "" { + delete(userInput, "oauth_token") + zerolog.Ctx(ctx).Debug(). + Str("oauth_redirect_url", oauthRedirectURL). + Msg("Google OAuth reached the Meta redirect URL") + return nil, fmt.Errorf("google sign-in not yet fully implemented") + } + + b.DisplayedURL = "" + err = oauthButton.TapButton(ctx, b.CurrentPage.Interpreter) if err != nil { return nil, fmt.Errorf("tapping verify: %w", err) } @@ -2003,7 +2015,20 @@ func (b *Browser) DoLoginStep(ctx context.Context, userInput map[string]string) Required: true, Sources: []bridgev2.LoginCookieFieldSource{{Type: bridgev2.LoginCookieTypeSpecial, Name: "oauth_token"}}, }}, - ExtractJS: `new Promise((resolve, reject) => reject("not implemented yet"))`, + ExtractJS: `new Promise((resolve, reject) => { + const url = new URL(window.location.href); + const isMetaHost = ["m.facebook.com", "www.facebook.com", "web.facebook.com"].includes(url.hostname); + if (!isMetaHost || url.pathname !== "/oauth2/redirect/") { + return; + } + const fragment = new URLSearchParams(url.hash.slice(1)); + const error = url.searchParams.get("error") || fragment.get("error"); + if (error) { + reject(new Error("Google OAuth failed: " + error)); + return; + } + resolve(window.location.href); + })`, }, }