-
-
Notifications
You must be signed in to change notification settings - Fork 157
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
Can't connect to Outlook OAuth IMAP #81
Comments
Hi @EthraZa , In order to get some additional context you could enable the debug mode to see the communication with the mail server.
If the TLS encryption method results in a timeout, the server is not responding. Maybe it's not supported by the server or runs under a different port? Instead of using oAuth, could you generate an "app password" and use it instead? Best regards, |
Hi. Basic Auth:
OAuth:
OAuth Log: I'm not sure, but it seems it's connecting to IMAP server, but failing elsewhere, maybe after authentication, don't know. About App Password, it looks like it will not work for me because it needs 2FA and my system is a server-side app that collect emails attachments and need to work without user intervention. Anyways Google, Microsoft and everybody else seems to think that OAuth is the way to go and will deprecate other forms of login in the near future. |
Hi @EthraZa , Please try to connect to the mail server via cli: openssl s_client -crlf -connect outlook.office365.com:993 ..and enter:
I suspect you'll receive something like this: If so this would indicate that the auth payload
is invalid. Try to update L393 and replace echo base64_encode("user={User}\001auth=Bearer {Token}\001\001"); If you receive something else as a response, please let me know. I'm aware of the upcoming changes regarding Google and Microsoft :) Best regards and thanks a lot for testing and debugging. |
I have tryed the openssl command with access_tokens generated before and after changing line 393, both have returned: Here is the full session after change the line:
Response from php-imap after line changing:
|
According to these two the payload should be correct and the request as well, or am I missing something? |
Now I am feeling a mixture of shame (of not RTFM), anger (to the M$) and relief (to get things work). According to the issue 87, the guy find out that the scope should be https://outlook.office365.com/IMAP.AccessAsUser.All instead of https://graph.microsoft.com/IMAP.AccessAsUser.All. Thank you so much for your attention. Webklex rocks. |
Hi @EthraZa , Thanks again, Update 22.01.2021: |
Hi @freescout-helpdesk , Here are some more information:
Best regards, |
When I try to add https://outlook.office365.com/IMAP.AccessAsUser.All it doesn't show up. The Azure does have the https://graph.microsoft.com/IMAP.AccessAsUser.All. |
Connection to MS365 was working fine, but since recently we can't connect it via OAuth. Does anybody knows if Microsoft made some changes to their Azure system?
We are using the following endpoints: Example of failed IMAP connection:
UPDATE: |
Do you guys know how to have a longer lifetime of the token? (in azure) |
Thanks for sharing. In my case, I must set the scope to ' https://outlook.office365.com/IMAP.AccessAsUser.All ' or the token won't work. I'm using o365 services with custom domain name. |
Thanks @EthraZa for prompting the solution. |
I have hijacked the issue #50 but I guess it's better to create a new one.
In the outlook webapp it says the IMAP info is:
Host: outlook.office365.com
Port: 993
Method: TLS
In the Azure panel, I have setup a Web authenticated App with Access Tokens and ID Tokens enabled, Live SDK Yes and Public client No.
With the following APIs permissions:
-- email
-- IMAP.AccessAsUser.All
-- offline_access
-- openid
-- profile
-- User.Read
I'm getting the tokens via oauth2-azure plugin for PHP League's OAuth 2.0 Client setting the scope as 'openid profile email offline_access %root%/IMAP.AccessAsUser.All %root%/User.Read'.
The MS Activity Page shows only my ok browser logins, nothing to validate there.
I got Google OAuth IMAP working in the same day, but after almost a week, Outlook is driving me nuts.
With SSL encryption Webklex/php-imap returns "Connection setup failed" and logs out "NOTICE: PHP message: got failure response: NO AUTHENTICATE failed.".
With TLS secutity it hangs till time-out after Nginx 1 minute limit.
Any ideas?
The text was updated successfully, but these errors were encountered: