simonrob / email-oauth2-proxy

An IMAP/POP/SMTP proxy that transparently adds OAuth 2.0 authentication for email clients that don't support this method.
Apache License 2.0
850 stars 95 forks source link

Google Mail and POP3 #171

Closed abreuferr closed 1 year ago

abreuferr commented 1 year ago

Simon Robinson

I have managed to configure the 'email-oauth2-proxy' software to function with Google Mail and Microsoft Office 365, utilizing the IMAP protocol. I am currently experiencing trouble with Google's POP3 protocol.

$ cat /etc/email-oauth2-proxy/settings.cfg

[emailproxy] delete_account_token_on_password_error = True encrypt_client_secret_on_first_use = False allow_catch_all_accounts = True

[IMAP-2993] server_address = imap.gmail.com server_port = 993

[POP-2995] server_address = pop3.gmail.com server_port = 995

[SMTP-2465] server_address = smtp.gmail.com server_port = 465

[@] redirect_uri = https://localhost/email-oauth2-proxy-authorize/ redirect_listen_address = http://127.0.0.1:8801/ token_url = https://oauth2.googleapis.com/token oauth2_scope = https://mail.google.com/ client_id = CLIENT_ID client_secret = CLIENT_SECRET permission_url = https://accounts.google.com/o/oauth2/auth

When I test with Thunderbird email software, I am getting the following error message below.

Jun 12 16:35:03 senhasegura email-oauth2-proxy - b7ce08ef9513[1375]: Caught asyncore info message in POP server at localhost:2995 (unsecured) proxying pop3.gmail.com:995 (SSL/TLS) - error : uncaptured python exception, closing channel <main.OAuth2Proxy listening localhost:2995 at 0x7f2eded0b810> (<class 'socket.gaierror'>:[Errno -2] Name does not resolve [/usr/local/lib/python3.11/asyncore.py|read|88] [/usr/local/lib/python3.11/asyncore.py|handle_read_event|419] [/email-oauth2-proxy/emailproxy.py|handle_accept|1651] [/email-oauth2-proxy/emailproxy.py|handle_accepted|1662] [/email-oauth2-proxy/emailproxy.py|init|1462] [/email-oauth2-proxy/emailproxy.py|init|1305] [/usr/local/lib/python3.11/asyncore.py|connect|336])

I've made a number of changes to the software's configuration file and unfortunately I'm still unsuccessful. Any idea what could be wrong in the config file?

best regards,

caio abreu ferreira

simonrob commented 1 year ago

What version of the proxy are you using? (python emailproxy.py --version)

The error is not one I've seen before, but I suspect this is something to do with IPv4 vs. IPv6 binding. It is worth trying specifying a local_address value (see the documentation) – for example, 127.0.0.1 or ::1.

abreuferr commented 1 year ago

What version of the proxy are you using? (python emailproxy.py --version) version = '2022-12-23' # ISO 8601 (YYYY-MM-DD)

cat /etc/senhasegura/email-oauth2-proxy/settings.cfg

[POP-2995] local_address = 127.0.0.1 server_address = pop3.gmail.com server_port = 995

[SMTP-2465] local_address = 127.0.0.1 server_address = smtp.gmail.com server_port = 465

I made the changes and the problem remains the same.

best regards,

simonrob commented 1 year ago

Please could you post the full proxy log that includes this error message? (in --debug mode)

abreuferr commented 1 year ago

Simon Robinson

I found the error. I was using 'pop3.gmail.com' instead of 'pop.gmail.com'.

Now, I have another problem with the pop3, message attachment file. error.txt

best regards,

simonrob commented 1 year ago

Please upgrade to the latest version of the proxy and try again?

simonrob commented 1 year ago

I'm going to assume that this is now resolved, but please feel free to re-open if that is not the case.