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
786 stars 84 forks source link

Client not authenticated to send mail. #2 #258

Closed SnakeSK closed 2 months ago

SnakeSK commented 2 months ago

Since the #257 was closed without actually solving the underlying issue (why are you closing the issue? Is there any problem of having the issues opened?)

Even after configuring the tenant id instead of common, changing oauth scopes, adding redirect and updating the azure ad app to the redirect uri, we are still getting oserror 22

2024-06-27 18:57:56,527: Running in a packaged/frozen environment - imported SSL certificates from certifi 2024-06-27 18:57:56,605: Initialising Email OAuth 2.0 Proxy (version 2024-05-25) from config file C:\Program Files (x86)\OAuth Proxy\emailproxy.config 2024-06-27 18:57:56,605: Starting SMTP server at 192.168.X.X:1587 (unsecured) proxying smtp.office365.com:587 (STARTTLS) 2024-06-27 18:57:56,605: Initialised Email OAuth 2.0 Proxy - listening for authentication requests. Connect your email client to begin 2024-06-27 18:58:08,886: Setting debug mode: True 2024-06-27 19:00:34,368: New incoming connection to SMTP server at 192.168.X.X:1587 (unsecured) proxying smtp.office365.com:587 (STARTTLS) 2024-06-27 19:00:34,368: Accepting new connection from 192.168.184.250:31241 to SMTP server at 192.168.X.X:1587 (unsecured) proxying smtp.office365.com:587 (STARTTLS) 2024-06-27 19:00:34,416: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587) --> [ Client connected ] 2024-06-27 19:00:34,431: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587)     <-- b'220 VI1PR04CA0050.outlook.office365.com Microsoft ESMTP MAIL Service ready at Thu, 27 Jun 2024 17:00:33 +0000\r\n' 2024-06-27 19:00:34,431: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587) <-- b'220 VI1PR04CA0050.outlook.office365.com Microsoft ESMTP MAIL Service ready at Thu, 27 Jun 2024 17:00:33 +0000\r\n' 2024-06-27 19:00:34,431: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587) --> b'EHLO SRV3\r\n' 2024-06-27 19:00:34,431: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587)     --> b'EHLO SRV3\r\n' 2024-06-27 19:00:34,447: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587)     <-- b'250-VI1PR04CA0050.outlook.office365.com Hello [5.178.56.180]\r\n' 2024-06-27 19:00:34,447: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587)     <-- b'250-SIZE 157286400\r\n' 2024-06-27 19:00:34,447: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587)     <-- b'250-PIPELINING\r\n' 2024-06-27 19:00:34,447: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587)     <-- b'250-DSN\r\n' 2024-06-27 19:00:34,447: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587)     <-- b'250-ENHANCEDSTATUSCODES\r\n' 2024-06-27 19:00:34,447: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587)     <-- b'250-STARTTLS\r\n' 2024-06-27 19:00:34,447: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587)     <-- b'250-8BITMIME\r\n' 2024-06-27 19:00:34,447: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587)     <-- b'250-BINARYMIME\r\n' 2024-06-27 19:00:34,447: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587)     <-- b'250-CHUNKING\r\n' 2024-06-27 19:00:34,447: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587)     <-- b'250 SMTPUTF8\r\n' 2024-06-27 19:00:34,447: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587)     --> b'STARTTLS\r\n' 2024-06-27 19:00:34,478: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587)     <-- b'220 2.0.0 SMTP server ready\r\n' 2024-06-27 19:00:34,478: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587) <-> [ Starting TLS handshake ] 2024-06-27 19:00:34,697: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587) [ Successfully negotiated SMTP server STARTTLS connection - re-sending greeting ] 2024-06-27 19:00:34,712: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587)     --> b'EHLO SRV3\r\n' 2024-06-27 19:00:34,759: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587) <-> [ TLSv1.3 handshake complete ] 2024-06-27 19:00:34,791: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587)     <-- b'250-VI1PR04CA0050.outlook.office365.com Hello [5.178.56.180]\r\n' 2024-06-27 19:00:34,791: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587)     <-- b'250-SIZE 157286400\r\n' 2024-06-27 19:00:34,791: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587)     <-- b'250-PIPELINING\r\n' 2024-06-27 19:00:34,791: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587)     <-- b'250-DSN\r\n' 2024-06-27 19:00:34,791: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587)     <-- b'250-ENHANCEDSTATUSCODES\r\n' 2024-06-27 19:00:34,791: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587)     <-- b'250-AUTH LOGIN XOAUTH2\r\n' 2024-06-27 19:00:34,791: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587)     <-- b'250-8BITMIME\r\n' 2024-06-27 19:00:34,791: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587)     <-- b'250-BINARYMIME\r\n' 2024-06-27 19:00:34,791: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587)     <-- b'250-CHUNKING\r\n' 2024-06-27 19:00:34,791: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587)     <-- b'250 SMTPUTF8\r\n' 2024-06-27 19:00:34,791: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587) <-- b'250-VI1PR04CA0050.outlook.office365.com Hello [5.178.56.180]\r\n250-SIZE 157286400\r\n250-PIPELINING\r\n250-DSN\r\n250-ENHANCEDSTATUSCODES\r\n250-AUTH PLAIN LOGIN\r\n250-8BITMIME\r\n250-BINARYMIME\r\n250-CHUNKING\r\n250 SMTPUTF8\r\n' 2024-06-27 19:00:34,791: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587) --> b'AUTH login [[ Credentials removed from proxy log ]]\r\n' 2024-06-27 19:00:34,791: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587) <-- b'334 UGFzc3dvcmQ6\r\n' 2024-06-27 19:00:34,791: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587) --> b'[[ Credentials removed from proxy log ]]' 2024-06-27 19:00:34,791: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587)     --> b'AUTH XOAUTH2\r\n' 2024-06-27 19:00:34,806: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587)     <-- b'334 \r\n' 2024-06-27 19:00:35,197: Caught exception while requesting OAuth 2.0 credentials for account email@email.com: OSError(22, 'Invalid argument') 2024-06-27 19:00:35,197: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587)     --> b'*\r\n' 2024-06-27 19:00:40,213: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587)     <-- b'535 5.7.3 Authentication unsuccessful [VI1PR04CA0050.eurprd04.prod.outlook.com 2024-06-27T17:00:40.197Z 08DC954D1D4D8E17]\r\n' 2024-06-27 19:00:40,213: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587) <-- b'535 5.7.8  Authentication credentials invalid. Email OAuth 2.0 Proxy: Login failed for account email@email.com - please check your internet connection and retry\r\n' 2024-06-27 19:00:40,213: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587) --> b'MAIL FROM:<email@email.com>\r\n' 2024-06-27 19:00:40,213: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587)     --> b'MAIL FROM:<email@email.com>\r\n' 2024-06-27 19:00:45,243: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587)     <-- b'530 5.7.57 Client not authenticated to send mail. Error: 535 5.7.3 Authentication unsuccessful [VI1PR04CA0050.eurprd04.prod.outlook.com 2024-06-27T17:00:45.228Z 08DC954D1D4D8E17]\r\n' 2024-06-27 19:00:45,243: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587) <-- b'530 5.7.57 Client not authenticated to send mail. Error: 535 5.7.3 Authentication unsuccessful [VI1PR04CA0050.eurprd04.prod.outlook.com 2024-06-27T17:00:45.228Z 08DC954D1D4D8E17]\r\n' 2024-06-27 19:00:45,243: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587) <-- [ Server disconnected ] 2024-06-27 19:00:45,243: SMTP (192.168.184.250:31241-{192.168.X.X:1587}-smtp.office365.com:587) --> [ Client disconnected ]
simonrob commented 2 months ago

I closed the other issue because from what you posted it seemed like a simple misconfiguration or misunderstanding, and issues are used for tracking bugs in the proxy, rather than as a support forum. I don't have capacity to offer tailored support here, except on a consultancy basis.

Since you've now posted more information and context, let's switch back to the original issue.