Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding smtp after using oauth2 for imap #21

Closed
dschwilk opened this issue Oct 3, 2022 · 3 comments
Closed

Adding smtp after using oauth2 for imap #21

dschwilk opened this issue Oct 3, 2022 · 3 comments

Comments

@dschwilk
Copy link

dschwilk commented Oct 3, 2022

Thank you for oauth2ms! This helped me continue to use emacs mbsync and mu4e when my university forced oauth2 imap this summer. At that time, smtp did not yet require oauth2 so I did not add code to my mu4e setup to use oauth2. That changed today. Therefore, I added to my .emacs based on the code in steps.org. I also made sure the config.json file had

   "scopes": ["https://outlook.office365.com/IMAP.AccessAsUser.All", "https://outlook.office365.com/SMTP.Send"]

And I had already set the smtp permissions in azure.

But attempting to send smtp results in an smtp trace like shown below (I deleted the token string). Any suggestion on where to start?

220 SN7P220CA0005.outlook.office365.com Microsoft ESMTP MAIL Service ready at Mon, 3 Oct 2022 15:50:36 +0000
250-SN7P220CA0005.outlook.office365.com Hello [<ip address>]
250-SIZE 157286400
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-8BITMIME
250-BINARYMIME
250-CHUNKING
250 SMTPUTF8
220 2.0.0 SMTP server ready
250-SN7P220CA0005.outlook.office365.com Hello [<ip address>]
250-SIZE 157286400
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-AUTH LOGIN XOAUTH2
250-8BITMIME
250-BINARYMIME
250-CHUNKING
250 SMTPUTF8
AUTH XOAUTH2 

[TOKEN CHUNK HERE DELETED]

535 5.7.3 Authentication unsuccessful [SN7P220CA0005.NAMP220.PROD.OUTLOOK.COM]
QUIT
221 2.0.0 Service closing transmission channel
@nbarrientos
Copy link

Try removing the credentials cache (this will remove your refresh token) and getting a new one.

$ rm ~/.local/share/oauth2ms/credentials.bin

and then execute oauth2ms again.

@dschwilk
Copy link
Author

Luckily I just moved the credentials.bin out of the way. Something seems to have changed and new credentials do not download. I am getting webpage with "Authorization complete" as reported in #22 and no new credentials.bin ... imap at least working with the old credentials.bin

@dschwilk
Copy link
Author

dschwilk commented Oct 20, 2022

Thank you @nbarrientos for this. A new refresh token was what was needed. The reason this did not work immediately for me was my own carelessness: in previous testing and experimenting I had put the wrong url for the smtp scope in config.json. For my setup it needed to be

"scopes": ["https://outlook.office365.com/IMAP.AccessAsUser.All","https://outlook.office365.com/SMTP.Send"]

Although the localhost webpage that oath2ms returned stated "Authorization complete.", the url string showed that it had not worked eg:

The+resource+principal+named+https%3a%2f%2fsmtp.office365.com+was+not+found+in+the+tenant+named ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants