owainlewis / clojure-mail

A Clojure library for parsing, downloading and reading email from IMAP servers.
203 stars 54 forks source link

README #21

Open clojens opened 9 years ago

clojens commented 9 years ago

There are several issues when I try to run this project. For one, a while now, I haven't been able to connect to Google GMail via IMAP. I had to resort to OAuth2 Java service api libs for my gmail connection. Same here, I get bounced with invalid credentials (they aren't I'm sure and have been using them non-stop these two days with webdriver to automate oauth2 consent click.

Second thing is that the readme, at least in my case again, naming a var def store while already having a name like that in your project results in conflicts. So I renamed to store-1 before I could get invalid credentials anyway.

Third, inbox doesn't work but I guess this is due to credentials...

Anyway my question really should be: does anyone have this working without fully disabling gmail account security (less secure apps) or is that always a result that comes with this approach...

ikarth commented 9 years ago

It worked for me, though I set up an app-specific password so I didn't need to toss around my real password. I suspect Google may bounce rapidly repeating connections as suspicious.

robjens commented 9 years ago

You must be running it in your own app context then (sorry, I'm user clojens btw). If you import symbols e.g. into the namespace (ns example) as (require '[something :refer :all]) and something contains a exported var foo, then you can't use foo as a name in (def foo ...).

Your project has a var named store and as such, that name is not usable anymore as a var. Yet in the readme, your example shows to end-user how to use the lib with a example var declared store. How is that ever going to work? I fail to see... Or do I have a brain fart (again)? :)

owainlewis commented 9 years ago

Hey. This is probably just an over sight on my part when writing the README. I'll take a look.

The best way to deal with this would be to alias the library (which I generally prefer anyway)

Example

(ns your-namespace
  (:require [clojure-mail.core :as mail]))

(def store (mail/gen-store "user@gmail.com" "password"))

Sorry for any confusion. I will have to update the documentation when I get a moment.

Does that make sense? Thanks

Owain

robjens commented 9 years ago

Thank you. I know cargo-cult coding is bad but it really isn't if you basically grok what you are doing. Unless it is a very elaborate procedure, which needs to have parts truncated, I'd expect a 'quick start' to work out of the box... Hopefully not using :use since that stuff is borderline to be deprecated for a while and really not the best of practice. Not sure if that was the case but anyway.

One more addition might be to highlight that one already needs to have run through part of the OAuth2 process before you can use this. Meaning: you need to have a access token to do anything at the minimum, correct? I don't see this library facilitating anything on the front of authorization in that respect.

This actually posed a problem for me, obtaining a token without user interference but thats a different story I solved using clj-webdriver clicking me through user consent and then fetching header callback param auth code sent by Google in response to the authorization request. Not the best but at least it works. Google OAuth2 service accounts need some lovin' in the documentation - extremely vague if and how it works with Gmail.

Anyway, cheers.

Rob

robjens commented 9 years ago

Exact (except namespace) copy/paste as instructed - conflicting names: 1

Change the name resolves the conflict 2

Yet the following really stops it (the user/pass is correct but obfuscated, without a correct one, the second expression, last blue one, would have failed as in the screenshot above). The method actually is missing. 3

Finally there is a paren too many (not balanced) see highlighted token 4