2e0byo / email

XOauth2 Scripts
MIT License
4 stars 4 forks source link

refresh error when using o365 ... #7

Open vladandersb opened 1 month ago

vladandersb commented 1 month ago

Just finished setting up everything but getting error below.

email-auth --refresh otest@um.com

Traceback (most recent call last):
  File "/home/um_tech/.local/bin/email-auth", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/um_tech/.local/pipx/venvs/email-auth/lib/python3.11/site-packages/email_auth/cli.py", line 20, in main
    account.write_refresh_token()
  File "/home/um_tech/.local/pipx/venvs/email-auth/lib/python3.11/site-packages/email_auth/creds.py", line 39, in write_refresh_token
    token = self.refresh_token()
            ^^^^^^^^^^^^^^^^^^^^
  File "/home/um_tech/.local/pipx/venvs/email-auth/lib/python3.11/site-packages/email_auth/creds.py", line 151, in refresh_token
    authcode = self.get_authcode(url, PORT)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/um_tech/.local/pipx/venvs/email-auth/lib/python3.11/site-packages/email_auth/creds.py", line 127, in get_authcode
    resp_url = self.get_response_url(url, port)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/um_tech/.local/pipx/venvs/email-auth/lib/python3.11/site-packages/email_auth/creds.py", line 112, in get_response_url
    assert keyf.exists() and certf.exists()
AssertionError

cat .config/email.toml

[accounts.otest]
token_file = "~/.pass/otest"
email = "otest@um.com"
type = "o365"

[accounts.bar]
token_file = "~/.pass/bar"
email = "barr@gmail.com"
type = "gmail"

Using minimal Debian 12 VM, ssh console.

2e0byo commented 3 weeks ago

interesting. Do the files in fact exist? sorry for the delay on responding. I may need to include them in the build; will try to test this soon.

vladandersb commented 3 weeks ago

No problem, just thought would let you know.

Installed everything per readme, poetry from system package python3-poetry. If you suspect something is missing, let me know.

Changing type to gmail seems to work, I didnt test it all the way but it didnt error out like o365 does.

2e0byo commented 2 weeks ago

Interesting; I no longer have an office365 account (but I can make one to test). I'll try to get on this today.

2e0byo commented 2 weeks ago

could you try #8? this should have fixed the particular error you saw (I had just forgotten to ship the cert and key...). However I'm unable to authenticate with this for an outlook.com email; the scopes requested are invalid. I can fix this, but I'll wait to see if it works for you or not before I go digging into thunderbird to see how they now do it.

Note that I bumped the python requirement to 3.12 largely to help poetry solve. Most everyone is on 3.12 these days but I can bump that down again (or you can, and run poetry lock) if you don't have it.

vladandersb commented 2 weeks ago

I would need to switch distro for newer python, Debian stable uses 3.11. Im not familiar with poetry, it might take me a while to figure out how to go around this limitation on Debian. I'll try spinning up VM with Arch or Fedora sometime this week.

2e0byo commented 2 weeks ago

oh nw I can do 3.11; I'll try to relock tonight. Btw if you want to test this stuff quickly docker run --rm -it python:3.12 bash is a lot easier than a vm. But I'm happy to support 3.11.