0

Some background: I am working on learning how to convert an app that uses a POP3 connection to use OAuth since Microsoft is dropping support for basic authentication in October. Initially I was using just POP3, but swapped to POP3_SSL after not being able to even enter a username. However, I've run across an issue authenticating with the password

import poplib
email_address = 'redacted@blank.com'
password = 'redacted'
pop3_server = 'outlook.office.com'
server = poplib.POP3(pop3_server)

server.set_debuglevel(1)

pop3_server_welcome_msg = server.getwelcome().decode('utf-8')

print(server.getwelcome().decode('utf-8'))

server.user(user=email_address)
server.pass_(password)

The error:

+OK The Microsoft Exchange POP3 service is ready. [UwBOADcAUABSADAANABDAEEAMAAxADkANgAuAG4AYQBtAHAAcgBkADAANAAuAHAAcgBvAGQALgBvAHUAdABsAG8AbwBrAC4AYwBvAG0A]
*cmd* 'USER redacted@blank.com'
*cmd* 'PASS redacted'
Traceback (most recent call last):
  File "testScript.py", line 89, in <module>
    server.pass_(password)
  File "c:\python27\lib\poplib.py", line 197, in pass_
    return self._shortcmd('PASS %s' % pswd)
   File "c:\python27\lib\poplib.py", line 160, in _shortcmd
     return self._getresp()
  File "c:\python27\lib\poplib.py", line 136, in _getresp
    raise error_proto(resp)
poplib.error_proto: -ERR Logon failure: unknown user name or bad password.

Copied project from here

Logging into the account via outlook the password works, but doesn't when running the script. If there is a step I have missed, please let me know. Thanks!

AWKO_LP
  • 1
  • 3
  • 2
    Are you aware that [Python 2.7 went EOL in 2020](https://www.python.org/doc/sunset-python-2/)? You should be using [3.7 at minimum](https://devguide.python.org/versions/). – wjandrea Aug 22 '22 at 19:55
  • BTW, welcome to Stack Overflow! Please take the [tour] and read [How to ask a good question](/help/how-to-ask). – wjandrea Aug 22 '22 at 19:56
  • 1
    @wjandrea I'm aware it's EOL, just a matter of finding a quick fix for the current system so I don't have to rush the update to 3.10. Multiple projects I'm on are using 2.7 unfortunately. At this point though it might be easier just to update and use OAuth2 instead of trying to do this gradually. – AWKO_LP Aug 23 '22 at 17:08
  • As it turns out, I was given the incorrect test email. The one I was using had advanced auth in place. Using an account with only basic auth works fine. Going to close this question. – AWKO_LP Aug 23 '22 at 17:35

1 Answers1

0

As it turns out, I was given the incorrect test email. The one I was using had advanced auth in place. Using an account with only basic auth works fine. Going to close this question.

AWKO_LP
  • 1
  • 3