7

I'm trying to connect and retrieve a list of message headers from Gmail via IMAP.

I'm getting a response from Google with "Web Login Required" and then a URL to continue the sign-in via the web interface. Log: http://hastebin.com/odufaducew.vhdl

Why does this happen? How to handle this case? I'm using the MailCore2 lib for iOS if that helps at all.

Mateusz Piotrowski
  • 8,029
  • 10
  • 53
  • 79
Andy Hin
  • 30,345
  • 42
  • 99
  • 142
  • Does [this answer](http://stackoverflow.com/a/25447206/113848) help? – legoscia Aug 29 '14 at 15:04
  • 1
    @legoscia Interesting. I will give that a try later today. I can't ask all my users to go and change that setting though ... how do I handle this from a product perspective? – Andy Hin Aug 29 '14 at 15:09

2 Answers2

10

You can enable access for less secure apps in this page Google - Less secure apps

Choose enable and try again!

araks
  • 40,738
  • 8
  • 34
  • 39
0

As legoscia points out, this happens when the login is done using a password and considered risky. The best option seems to be to avoid storing and using user's passwords for Gmail and instead switch to Oauth2. Is this app a mail user interface or are you using IMAP as an API? (Perhaps, https://developers.google.com/gmail/api/ would be more appropriate?)

Eric D
  • 6,901
  • 1
  • 15
  • 26
  • Wrong. The question (in title, in bold, on this page is), "Why am I getting ..." and the first sentence of my answer is "this happens when..." and then goes on to recommend how to avoid getting this error in the first place. You are incorrect saying this doesn't provide an answer to the question, it just doesn't provide the answer you want. – Eric D Oct 21 '15 at 19:13