-
Notifications
You must be signed in to change notification settings - Fork 37
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 Prevents Login from Automated Test Software #37
Comments
I just found this issue: chromedp/chromedp#996 (comment) |
You can get this to work if you disable web security (you will have to specify a user data directory). (I finally got this working last night.) |
Thanks @mholt for digging into this, is this what you are referring to: https://medium.com/@dmadan86/run-chrome-browser-without-cors-by-disabling-web-security-d124ad4dd2cf I am going to try this out later this evening! |
Yep, those are the flags I set. Obviously, only access trusted sites with that flag. |
@mholt / @mullender , where/how do you actually set the --disable-web-security flag? |
When you run Chrome. It's a command line flag. If you're using a headless browser, the automation lib should let you specify flags. |
I added the following flags to the retrieval script, and it still failed to authenticate
|
Ah, to clarify, I don't use the default flags: opts := []chromedp.ExecAllocatorOption{
chromedp.NoFirstRun,
chromedp.NoDefaultBrowserCheck,
chromedp.UserDataDir("/home/matt/.config/google-chrome"),
chromedp.Flag("enable-automation", true),
chromedp.Flag("disable-web-security", true),
chromedp.Flag("allow-running-insecure-content", true),
} |
its also failing for me, even with settings of @mholt
|
It also fails for me with the screenshot in the first comment. I wonder if it depends on whether we have 2FA enabled. I do. Does authentication work out of the box for anyone? |
Could someone describe how to succeed with authentication from scratch? I've cloned the repo and installed golang. $ go run main.go shows the "Couldn't sign you in" screen. $ go run main.go --help doesn't really point how to set "the flags". Could anybody who is able to log in with a @gmail.com account describe what they did in a little more detail? |
@pmorch This worked for me (see above): #37 (comment) |
Ok, thanks. I have multiple profiles in the default user-data-dir, so I created a brand new one with: $ google-chrome --user-data-dir=/home/pmorch/work/gphotos-cdp/google-chrome and then applied this patch: diff --git a/main.go b/main.go
index 5b457b2..fb45df8 100644
--- a/main.go
+++ b/main.go
@@ -155,10 +155,14 @@ func NewSession() (*Session, error) {
func (s *Session) NewContext() (context.Context, context.CancelFunc) {
// Let's use as a base for allocator options (It implies Headless)
- opts := append(chromedp.DefaultExecAllocatorOptions[:],
- chromedp.DisableGPU,
- chromedp.UserDataDir(s.profileDir),
- )
+ opts := []chromedp.ExecAllocatorOption{
+ chromedp.NoFirstRun,
+ chromedp.NoDefaultBrowserCheck,
+ chromedp.UserDataDir("/home/pmorch/work/gphotos-cdp/google-chrome"),
+ chromedp.Flag("enable-automation", true),
+ chromedp.Flag("disable-web-security", true),
+ chromedp.Flag("allow-running-insecure-content", true),
+ }
if !*headlessFlag {
// undo the three opts in chromedp.Headless() which is included in DefaultExecAllocatorOptions And then ran: $ go run main.go -n 20 -dldir /home/pmorch/work/gphotos-cdp/photos Now it works. I see the photos in |
Thanks @pmorch for the patch! It worked for me following your instructions, except I had to log in first with the profile and authenticate, before running gphotos-cdp. After pre-authenticating, then it worked. |
Steps to repro:
go run main.go -dev -v
In another attempt I launched chrome without automation but with the data dir set to the same location as gphoto-cdp uses:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --user-data-dir=/var/folders/tt/5skfg0yd4q1bwhr_fh_0t39h0000gn/T/gphotos-cdp
go run main.go -dev -v
And my apologies for yesterday's issue.
The text was updated successfully, but these errors were encountered: