Giter VIP home page Giter VIP logo

Comments (6)

maerten avatar maerten commented on August 21, 2024

Closing, I guess it had to do with Google's security settings, not the library itself.

from haskellnet-ssl.

dpwright avatar dpwright commented on August 21, 2024

Yeah, this was reported a while back on haskell-cafe -- the reason is that Google now calls any app which doesn't use OAuth 2 "insecure", and by default disables it for accounts not using two-factor authentication. You can re-enable it here:

https://www.google.com/settings/security/lesssecureapps

I think normal password logins do work if you have 2FA enabled and you generate an app-specific password for your account, so if you don't want to enable a setting called "allow less secure apps to access my account" (!), you could do that instead.

I have started work on connecting with OAuth 2, though currently that's just locally on my machine and not pushed yet, and it's taken a bit of a back-seat to other work I have going on. I may push the branch in the state it's currently in, in case anyone else wants to get it working...

from haskellnet-ssl.

maerten avatar maerten commented on August 21, 2024

I havent found another haskell lib that provides easy Gmail with OAuth 2 yet, and it would be nice to avoid 2FA for this particular app I'm building (it uses a shared gmail account). So I would be very interested to try it out for the next version of the app I'm working on.

At the very least I could test out your oAuth 2 branch and report the results.

Thanks!

from haskellnet-ssl.

dpwright avatar dpwright commented on August 21, 2024

OK, I've pushed my WIP commit here: dpwright/HaskellNet@d7311ee

I'd forgotten, but as this is nothing to do with SSL/TLS the change required is to https://github.com/jtdaugherty/HaskellNet, not HaskellNet-SSL. The code in that commit looks like it should work according to the spec, but the server returned an error when I tested it. I didn't spend an awful lot of time with it.

I think I'll reopen this issue while we're talking about it, in case anybody else has trouble with the gmail example...

from haskellnet-ssl.

auermich93 avatar auermich93 commented on August 21, 2024

There is a logical error in the code. If authentication works, it will always print: "Authentication error."
The if-statement is wrong. Add 'not' before 'authSucceed', then it will work. Moreover, as above suggested, it is mandatory to enable access from less secure apps, otherwise an exception will be thrown.

smtpTest = doSMTPSTARTTLS "smtp.gmail.com" $ \c -> do
    authSucceed <- SMTP.authenticate LOGIN username password c
    if (**not** authSucceed)
      then print "Authentication error."
      else sendPlainTextMail recipient username subject body c
  where subject = "Test message"
body = "This is a test message"

from haskellnet-ssl.

Hazelfire avatar Hazelfire commented on August 21, 2024

I will close this issue as it's not related to this repository, and requires using OAuth. If anyone is interested in accessing Gmail without enabling access to "insecure apps", https://hackage.haskell.org/package/gogol-gmail looks promising. If you want to use IMAP/SMTP/HaskellNet using OAuth, I'd recommend opening a related issue in https://github.com/jtdaugherty/HaskellNet.

from haskellnet-ssl.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.