javanile / php-imap2

PHP IMAP with OAUTH2
https://php-imap2.javanile.org/
GNU General Public License v3.0
51 stars 31 forks source link

Issue connecting to IMAP #55

Open Black-Dragon-Spirit opened 1 year ago

Black-Dragon-Spirit commented 1 year ago

When using an application token (without user) it's not possible to connect (authenticate) to the server. Tried dividend scopes for the token: https://graph.microsoft.com/.default https://outlook.office.com/.default https://outlook.office365.com/.default

All the permissions are set.

tiamatloc commented 1 year ago

@Black-Dragon-Spirit When using an application token you are authenticating to Azure, NOT the mailbox (or you could read any of them in a corporate 365 environment). The error is correct, but a bit misleading. You have to use the Enterprise application and use a service principle to authorise delegate access to the mailbox(es) as if you would granting Bob access to Alice's mailbox when Alice goes on vacation. https://outlook.office365.com/.default is the correct scope to use.

https://vielhuber.de/en/blog/access-with-php-to-exchange-office-365/ https://www.limilabs.com/blog/oauth2-client-credential-flow-office365-exchange-imap-pop3-smtp