To allow organizations to adhere to secure email requirements, AEM Forms offer OAuth 2.0 support for integration with Microsoft® Office 365 mail server protocols. You can use Azure Active Directory (Azure AD) OAuth 2.0 authentication service, to connect with various protocols such as IMAP, POP or SMTP and access email data for Office 365 users. Below are step-by-step instructions for configuring the Microsoft® Office 365 mail server protocols to authenticate via OAuth 2.0 service:
Login https://portal.azure.com/ and search for Azure Active Directory in the search bar and click on the result.
Alternatively, you can browse directly to https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/Overview
Click Add > App Registration > New Registration
Fill in the information according to your requirements, then click Register.
In the above case, Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft® accounts (for example, Skype, Xbox) option is selected.
Next, go to Certificates and Secrets, click New client secret and follow the on-screen steps to create a secret. Make sure to take note of this value of secret for later use.
For adding permissions, go to the newly created app, and select API Permissions > Add a Permission > Microsoft® Graph > Delegated Permissions
Select the checkboxes for the below permissions for the app and click Add Permission:
IMAP.AccessUser.All
Mail.Read
offline_access
POP.AccessAsUser.All
SMTP.Send
User.Read
Select Authentication > Add a platform > Web, and in the Redirect Urls section, add any of the below URIs (Universal Resource Identifier) as:
https://login.microsoftonline.com/common/oauth2/nativeclient
http://localhost
In this case, https://login.microsoftonline.com/common/oauth2/nativeclient
is used as a redirect URI.
Click Configure after adding each URL and configure your settings according to your requirements.
It is mandatory to select Access tokens and ID tokens checkboxes.
Click Overview in the left-hand pane and copy the values for Application (client) ID, Directory (tenant) ID, and Client Secret for later use.
Next, you need to generate the authorization code, explained in the following steps:
Open the following URL in the browser after replacing clientID
with the <client_id>
and redirect_uri
with the redirect URI of your application:
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=[clientid]&scope=IMAP.AccessAsUser.All%20POP.AccessAsUser.All%20SMTP.Send%20User.Read%20Mail.Read%20offline_access&response_type=code&redirect_uri=[redirect_uri]&prompt=login
In case of the single tenant application, replace common
with your [tenantid]
in the following URL for generating authorization code: https://login.microsoftonline.com/[tenantid]/oauth2/v2.0/authorize?client_id=[[clientid]]&scope=IMAP.AccessAsUser.All%20POP.AccessAsUser.All%20SMTP.Send%20User.Read%20Mail.Read%20openid%20offline_access&response_type=code&redirect_uri=[redirect_uri]&prompt=login
When, you type the above URL, you are redirected to the login screen:
Enter the email, click Next and App permission screen appears:
Once you allow permission, you are redirected to a new URL as: https://login.microsoftonline.com/common/oauth2/nativeclient?code=<code>&session_state=[session_id]
Copy the value of <code>
from the above URL from 0.ASY...
to &session_state
in the above URL.
Next, you need to generate the refresh token, explained in the following steps:
Open the command prompt and use the following cURL command to get the refreshToken.
Replace the clientID
, client_secret
and redirect_uri
with the values for your application along with the value of <code>
:
curl -H “ContentType application/x-www-form-urlencoded” -d “client_id=[client-id]&scope=https%3A%2F%2Foutlook.office.com%2FIMAP.AccessAsUser.All%20https%3A%2F%2Foutlook.office.com%2FPOP.AccessAsUser.All%20https%3A%2F%2Foutlook.office.com%2FSMTP.Send%20https%3A%2F%2Foutlook.office.com%2FUser.Read%20https%3A%2F%2Foutlook.office.com%2FMail.Read%20offline_access&code=[code]&grant_type=authorization_code&redirect_uri=[redirect_uri]&client_secret=[secretkey_value]” -X POST https://login.microsoftonline.com/common/oauth2/v2.0/token
In single tenant application, to generate refresh token use the following cURL command and replace common
with the [tenantid]
in:
curl -H “ContentType application/x-www-form-urlencoded” -d “client_id=[client-id]&scope=https%3A%2F%2Foutlook.office.com%2FIMAP.AccessAsUser.All%20https%3A%2F%2Foutlook.office.com%2FPOP.AccessAsUser.All%20https%3A%2F%2Foutlook.office.com%2FSMTP.Send%20https%3A%2F%2Foutlook.office.com%2FUser.Read%20https%3A%2F%2Foutlook.office.com%2FMail.Read%20offline_access&code=[code]&grant_type=authorization_code&redirect_uri=[redirect_uri]&client_secret=[secretkey_value]” -X POST https://login.microsoftonline.com/[tenantid]/oauth2/v2.0/token
Make note of the refresh token.
Now, you have to configure e-mail service at latest JEE server by login in Admin UI:
Go to Home > Service > Application and Services > Service Management > Email Service, the Configuration Email service window appears, configured for basic authentication.
To enable oAuth 2.0 authentication service, it is mandatory to select Whether the SMTP server requires authentication (SMTP Authenticate) checkbox.
Set oAuth 2.0 Authentication Settings as True
.
Copy the values of Client ID and Client Secret from Azure Portal.
Copy the value of generated Refresh Token.
Login in to Workbench and search Email 1.0 from Activity Picker.
Three options are available under Email 1.0 as:
Test the application by selecting Send with Document.
Provide TO and From addresses.
Invoke the application and email is sent using the 0Auth 2.0 authentication.
If you want to change Auth 2.0 authentication setting to basic authentication for a particular process in a workbench, you can set the OAuth 2.0 Authentication value as ‘False’ under Use Global settings in the Connection Settings tab.
Go to Home > Services > Form Workflow > Server Settings > Email Settings
To enable oAuth task notifications, select the Enable oAuth checkbox.
Copy the values of Client ID and Client Secret from Azure Portal.
Copy the value of generated Refresh Token.
Click Save to save the details.
To know more information related to task notifications, click here.
Go to Home > Services > Application and Services > Endpoint Management
To configure email endpoint, set oAuth 2.0 Authentication Settings as True
.
Copy the values of Client ID and Client Secret from Azure Portal.
Copy the value of generated Refresh Token.
Click Save to save the details.
To know more information on configuring email endpoints, click on Configure an email endpoint.
If the e-mail service is not working properly. Try to regenerate the Refresh Token
as described above. It takes a few minutes for the new value to be deployed.
Error while configuring e-mail server details in email endpoint using Workbench.Try to configure endpoint via Admin UI instead of Workbench.