How can I avoid google mail server asking me to log in via browser?

夙愿已清 提交于 2019-11-27 18:08:14
Hasan Veli Soyalan

Just go to https://accounts.google.com/DisplayUnlockCaptcha and click "continue". This is going to allow access from other servers.

etusm

I've been messing with this for a couple of hours within a cucumber/capybara/selenium test - discovered something stupid which will fix this error for good, guaranteed

The all too familiar error:

Please log in via your web browser: https://support.google.com/mail/accounts/answer/78754 (Failure) (Net::IMAP::NoResponseError)

As it turns out, there are TWO "Allow Less Secure Apps" toggles which need to be changed to allow logins from unknown devices/IMAP.

One here: https://myaccount.google.com/security?pli=1#connectedapps (bottom of the page)

And one here: https://www.google.com/settings/security/lesssecureapps

BOTH OF THESE GODFORSAKEN TOGGLES need to be changed to get rid of this error message.

edit: from user Milothicus (https://stackoverflow.com/users/3538026/milothicus): in myaccount.google.com, under 'Sign-in & Security', select 'Connected apps & sites'. this also has an option to 'Allow less secure apps'. after turning this one on, my server could now send me an automated email.

When I tried to access my account I was sent this email consisting of this link. https://www.google.com/settings/security/lesssecureapps

You can turn-on then possibly turn-off after you've done testing.

I got the following response from Google Apps support:

You need to turn on your Outbound relay. To do this:

  1. Log into your account at google.com/a/yourdomain.com
  2. Click the Settings tab and then select Email in the left column.
  3. In the Outbound relay section, select Allow users to send mail through an external SMTP when configuring a "from" address hosted outside your domain.
  4. Click Save changes.

They also provided a help link: http://support.google.com/a/bin/answer.py?hl=en&answer=176054

After turning on Outbound relay and using the proxy to login to the webmail one more time (thanks to @DaniloBargen and @joshcartme) the issue was resolved. I've read the link explaining what the Outbound relay is and I'm not really sure why would I need it (I don't believe I'm using an external SMTP server).

Since I'm not really sure this is what solved the issue I won't mark the response as accepted until I get some confirmation.

Set up an ssh tunnel to the server in question so that you could, from your home computer, log in to the gmail web client using the server's IP. You probably need to tunnel port 80 and port 443, maybe just 443. After logging in through the web client the problem should go away according to knowledge base article listed in the SMTPAuthenticationError.

Here's an example of how to set up the tunnel: http://www.noah.org/wiki/SSH_tunnel#simple_port_forwarding_.28SSH_tunneling.29

Option #1 (this worked for me):

After getting the error Please log in with your web browser and then try again. Learn more etc. when trying to send email from my web application, I logged in to the email via browser from my local computer.

After I logged in, there was a yellow notification bar on top which asking me if I want to allow external application access my mail. I confirmed this and Google asked me to log in to the account from the application within the next 10 mins. This will white-list the application.

Option #2:

If Option #1doesn't work for you, try this: http://www.rocketideas.com/2012/05/gmail-error-password-not-accepted-from-server-solved/

etusm provided two locations to turn on less secure apps:

One here: https://myaccount.google.com/security?pli=1#connectedapps (bottom of the page)

And one here: https://www.google.com/settings/security/lesssecureapps

both were turned on, but my headless server still couldn't send me an email. based on JohnPang's google+ recommendation, i found a third location where i had to allow access to less secure apps:

in myaccount.google.com, under 'Sign-in & Security', select 'Connected apps & sites'. this also has an option to 'Allow less secure apps'. after turning this one on, my server could now send me an automated email.

I found the solution at: https://support.google.com/accounts/answer/185833?hl=en and finally https://security.google.com/settings/security/apppasswords

If you are testing your project on a local machine, you should go to the latter link, and enable "Access for less secure apps".

Do you have two factor authentication enabled for the apps account ? Then you might need to use an application specific password for that application.

All of the above doesn't help in my case (weird). But this link might help you:

https://security.google.com/settings/security/activity

You can access it via Google Plus

  1. Open Google+
  2. Select "Security" from the top
  3. Under "Recent activity" click "View all events"
  4. You will see a list of "Unusual Activity"
  5. It shows "Application / device sign-in attempt (prevented) Singapore" as I'm using AWS from Singapore
  6. Click on "Change" > "Yes, that was me!"
  7. Retry again. Done!

As of now (look at my post date) there is only one "Allow less secure apps" toggle in the Gmail account admin UI: https://myaccount.google.com/u/0/security#connectedapps

It'll work from your local computer (Mac or PC) after that.

To allow access from Amazon EC2 (and I suspect other Cloud-located hosts), there is yet another flag to set in Google's never ending battle with spammers: https://accounts.google.com/b/0/DisplayUnlockCaptcha

change your settings at https://www.google.com/settings/security/lesssecureapps so that your account is no longer protected by modern security standards.

This is occuring due to some apps are marked as less secure apps by google. So to use those apps, you need to give access for those apps. to do that follow http://www.codematrics.com/your-imap-server-wants-to-alert-you-to-the-following-please-login-via-your-web-browser-gmail/

Hope this will solve your issue.

In my case, when i tried to login to the google account via web, it asked me for a captcha. I entered the captcha and then the automation worked.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!