Outlook Calendar Integration Using Oauth2.0
Microsoft is ending support for basic authentication beginning 1st October 2022. thus we need to change the Authentication to Oauth2.0
Steps or guidelines to integrate outlook calendar
To integrate outlook calendar with your FreePBX you should have a licensed outlook account (personal or organization account) along with office 365 subscription. And the application needs to be registered with azure portal
Register application in: https://portal.azure.com
Steps to register application in azure portal
Login to https://portal.azure.com using your outlook account which has an office 365 subscription.
After logging in search and select App Registration in the top search box.
Click on new registration.
Enter the following details marked in the screen shot.
Name: Enter the name of the application as your convenience
Account Types: Please select second option (Any Azure AD directory - Multitenant)
Redirect URI: Select the web option from the redirect URI drop down and enter your PBX calendar module’s URI. This is optional at this step you can add this later after registering the application.Click on Register button to register the application
Note:
a. The redirect URI should always be your PBX url appended with the calendar module.
Ex : https://pbx.domain/admin/config.php?display=calendar
b. Your PBX domain should HTTPSNote: The HTTPS port should be open only when user trying to generate authorize token while adding Outlook Oauth2 config, once authorization done, they can disable https port if user wish.
5. After Registering the the application you will get the client details
Adding API permissions to the registered application
You can navigate to the API Permissions in the left navigation bar or you can click on Add a certificate or secret link on the below screenshot.
After navigating to API permissions click on add permission button to add permissions
Select Microsoft Graph -> Delegated Permissions -> select offline_access and Calendars.ReadWrite permissions -> click Add permission button
7. After adding permissions Grant admin consent for these permissions (this step is not mandatory). To grant that just click on Grant admin consent button.
8. Getting client secret key
Navigate to Certificates and secrets tab on left menu -> click on New client secret button -> enter description -> select expiration time -> Add
When a client secret is added it will show up in the list. Please note the client secrete value somewhere else safely as it is visible for only once after creation.
Authorizing the PBX to Read calendar events
Ensure FreePBX had HTTPS setup done and login to FreePBX system, Once outlook authorize token generation is done, user can disable to https port if they wish (Not a mandatory for viewing the calendar) Login to system using https and Go to the outlook Config page by clicking on the Outlook Oauth2 Config buttons calendar list page. Then Click on Add Config
2. Enter all the details which you got by completing the app registration in azure portal.
Click on Save.
After saving the credentials, it will redirect to allow api permission page, pls allow them, once done the Authorization button will be enabled.
If you are not getting redirected to allow the permission then Click Authorization button to generate Oath token for Microsoft APIs on clicking Authorize access button it will ask for Microsoft account login and access permission.
Please login with the Microsoft account which has proper office 365 subscription or else the outlook calendar sync will not work.
On allowing access it redirects back to the calendars module home page.
Select Add Remote Outlook Calendar using Oauth2 from the add calendar dropdown.
Add an outlook calendar by filling out all the required fields and selecting the outlook config created earlier (after entering the proper email and selecting proper config the users calendars are listed please select the desired calendar or else default user calendar will be selected automatically). Submit and save calendar
10. Go to calendar view and then click on update from source button to sync the calendar.