-
-
Notifications
You must be signed in to change notification settings - Fork 149
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
Guide / Tutorial to setup Outlook / Azure #264
Comments
I'm trying to do this now... it isn't easy. I can write something if I get it working. But I'm struggling to get it to work... got failure response: NO AUTHENTICATE failed. PHP Fatal error: Uncaught Webklex\PHPIMAP\Exceptions\AuthFailedException in C:\wamp64\www\imap_receiver\vendor\webklex\php-imap\src\Client.php:385 |
I've created an app password using Azure.... I'd have to write something up on how to do it, next time I'm in the website. |
These steps should allow you to connect to IMAP endpoint with authorised client application using oauth authentication to access specified mailboxes. You’ll need:
Azure Active Directory Login to Azure Active Directory with administrative permissons. Select App registrations, then New registration Given the app a name and select the support account type (I’ve only used Single tenant) Click Register From the Overview page of the app, Select API permissions, then Add a permission Select APIs my organization uses. Select Office 365 Exchange Online (you might need to search for it) then Application Permissions, then select the permission IMAP.AccessAsApp Tick the box, then click Add permissions Click Grant admin consent for tenant, then click Yes (as admin you’re allowing the app to be used on the tenant, with poweshell below you will link the app to specific mailboxes) Select Certificates & Secrets, then New Client Secret Give it a name and expiration and then click Add Make a note of the ‘Value’, this is your <clientSecret> From the main AzureAD page, select Enterprise applications Find your new application on the list and make a note of the Object ID – this is your <objectId> NB this is different from the Object ID which is shown on the app registration page Powershell (replace bold with your parameters) Install-Module -Name ExchangeOnlineManagement -allowprerelease New-ServicePrincipal -AppId <clientId> -ServiceId <objectId> Repeat the add-mailboxpermssion for required mailboxes. Get a token: // Replace bold with your parameters This will return a json message with the token Use the token as the password when making your ClientManager instance, and set the authentication parameter to oauth The token is only valid for an hour. Apparently, it can be renewed but I’m yet to try that. Credit goes Ricci Gian Maria at https://www.codewrecks.com/post/security/accessing-office-365-imap-with-oauth2/ for doing the hard work. This above is bear essentials that I've used from his write-up and videos |
Hi @knightcott-paul. After doing all the step you described, then what? How to correct set up laravel-imap? Thanks |
Hi, After doing the steps above you can use the token as the password when creating your ClientManager instance. Like this example If you're using Laravel, you can install the package with |
Hi @knightcott-paul thank you for answer me. The problem is that after doing all that, I'm still can't connect: << TAG1 NO AUTHENTICATE failed. "connection setup failed"
|
Same problem here. I have a plain exchange online instance and followed all the steps, but did not succeed. |
@vielhuber That was the clue!! Thank you!! And all this process has to be done, with a user, who has the "GLOBAL ADMINISTRATOR" Role |
Here is a Script for the getting the Token public function getOfficeToken3652($tenantID, $clientid, $clientSecret) |
Hi, The "object id" used with the PowerShell Cmdlet "New-ServicePrincipal" has to be the one from "ENTERPRISE APPLICATIONS", not from the "APPLICATION REGISTRATIONS". As perfectly shown in a screenshot on the following blog post: |
Hi Everyone,
I'm looking for someone who would like to create a tutorial with a step by step guide on how to setup Azure in order to use Outlook accounts (especially how to create an auth token which can be used to authenticate via IMAP).
Please let me know if you know of an tutorial / guide which already exist. I'm more than happy to link to it where ever I can :)
Thanks and happy coding,
The text was updated successfully, but these errors were encountered: