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

Google Login not working when browser is started with Rod #1033

Open
arjendevos opened this issue Mar 30, 2024 · 11 comments
Open

Google Login not working when browser is started with Rod #1033

arjendevos opened this issue Mar 30, 2024 · 11 comments

Comments

@arjendevos
Copy link

arjendevos commented Mar 30, 2024

Rod Version: v0.114.8

This is my startup code:

path, hasPath := launcher.LookPath()
	if !hasPath {
		panic("chrome not found")
	}
	fmt.Println("path found", path)

	l := launcher.New().
		Bin(path).
		Headless(false).
		Devtools(false).
		NoSandbox(true)
	defer l.Cleanup()

	url := l.MustLaunch()

	browser := rod.New().
		ControlURL(url).
		NoDefaultDevice().
		Trace(true).
		SlowMotion(1 * time.Second).
		MustConnect()

	defer browser.MustClose()

This sees the right chrome instance but when it starts it somehow starts unsecure.

Whenever I start the normal browser and add the websocket url in the Go program, it does work.

@arjendevos
Copy link
Author

Update: seems like google is detecting if the browser is run in debug-mode -> https://stackoverflow.com/a/59673634/13008147

@arjendevos
Copy link
Author

arjendevos commented Mar 30, 2024

Update: generated my own JS from the puppeteer stealth plugin with these 2 options:

const stealth = StealthPlugin()
stealth.enabledEvasions.delete('iframe.contentWindow')
stealth.enabledEvasions.delete('media.codecs')
puppeteer.use(stealth)

as mentioned here: berstend/puppeteer-extra#822 (comment)

Doesn't help

@arjendevos
Copy link
Author

Update: if I use .NewUserMode() with headless=false, it seems to work. However when I run it headlessly it fails, I thought due user-agent (includes headless) but overriding the user-agent doesn't work either

@ysmood
Copy link
Collaborator

ysmood commented Apr 4, 2024

You can use the FormatArgs to debug which cli arg is affecting it:

func Example_custom_launch() {
// get the browser executable path
path := launcher.NewBrowser().MustGet()
// use the FormatArgs to construct args, this line is optional, you can construct the args manually
args := launcher.New().FormatArgs()
var cmd *exec.Cmd
if true { // decide whether to use leakless or not
cmd = leakless.New().Command(path, args...)
} else {
cmd = exec.Command(path, args...)
}
parser := launcher.NewURLParser()
cmd.Stderr = parser
utils.E(cmd.Start())
u := launcher.MustResolveURL(<-parser.URL)
rod.New().ControlURL(u).MustConnect()
}

@arjendevos
Copy link
Author

Th only difference between running headless and running not headless is the user-data-dir. But that one is different on each run.

Not headless:

args [--disable-background-networking --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-default-apps --disable-dev-shm-usage --disable-features=site-per-process,TranslateUI --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --enable-automation --enable-features=NetworkService,NetworkServiceInProcess --force-color-profile=srgb --headless --metrics-recording-only --no-first-run --no-startup-window --remote-debugging-port=0 --use-mock-keychain --user-data-dir=/var/folders/sz/n6cyhc1x1qjd7m1wl04tn8mr0000gn/T/rod/user-data/9699488a8a9c9dc3]

Headless:

args [--disable-background-networking --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-default-apps --disable-dev-shm-usage --disable-features=site-per-process,TranslateUI --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --enable-automation --enable-features=NetworkService,NetworkServiceInProcess --force-color-profile=srgb --headless --metrics-recording-only --no-first-run --no-startup-window --remote-debugging-port=0 --use-mock-keychain --user-data-dir=/var/folders/sz/n6cyhc1x1qjd7m1wl04tn8mr0000gn/T/rod/user-data/2af72e923ad51328]

Also how is it possible that they both have the --headless flag?

@ysmood
Copy link
Collaborator

ysmood commented Apr 17, 2024

Could you try the v0.115.0

@arjendevos
Copy link
Author

@ysmood same problem

@ysmood
Copy link
Collaborator

ysmood commented Apr 17, 2024

Works fine to me:

package main

import (
	"github.com/go-rod/rod"
	"github.com/go-rod/rod/lib/utils"
)

func main() {
	browser := rod.New().NoDefaultDevice().MustConnect()

	page := browser.MustPage("https://google.com")

	page.MustElement(".gb_Ld").MustClick() // Click login

	utils.Pause()
}

@arjendevos
Copy link
Author

@ysmood fill out details until you are at the password input page. That's where it says that the browser is not secure.

@ysmood
Copy link
Collaborator

ysmood commented May 5, 2024

Still works fine to me after enter the mail address.

@cplasfwst
Copy link

我也是同样的问题,请问有解决办法吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants