
BTP - Connect Email via OAuth 2.0
Email integration via Basic Auth no longer works. What alternative options are available for connecting Office 365 to the ABAP environment and how can you configure them?
Table of contents
In one of the first articles about the ABAP Environment, we discussed the configuration of Office 365 and how you can apply everything within the ABAP Environment. Today, we present a follow-up article.
Introduction
Microsoft has deactivated Basic Authentication, i.e., login via username and password, for Outlook and Office 365. This login method is no longer considered the most secure, which is why Microsoft wants to disable it. This means that we now have to switch our configuration in the ABAP Environment to one of the new methods. In this article, we will therefore take a look at OAuth 2.0, and in particular the two different methods that are possible. The article took a little longer to write because, especially at the beginning, the use of OAuth 2.0 for the Communication Arrangement was not initially planned and had to be implemented by SAP.
Azure
To begin with the basic configuration, we need to make settings in Azure, as these are important for logging in. You therefore need an Azure account, where your email address is usually also registered, to connect to the server. Furthermore, you are either an administrator or know the administrators of the account in order to make later configurations.
Application
So first log in to the Azure Portal and then navigate to the Entra Service to make the configuration. There we need to create a new app registration. App registration is important to log in to the platform and obtain the necessary permissions. In the Entra section, you will find this option in the side menu under "App Registration". Click on it and you will find the "New application" button at the top to create a new application. We won't describe the individual steps in detail here; you can refer to the publicly available documentation from Microsoft.
Once the new application is available, you'll find the Display Name you specified during creation, as well as the Application ID, Object ID, and Directory ID on the overview page. We'll need this information in later steps, so you should make a note of it. The Application ID and Directory ID are particularly important here for the connection.
Permissions
To be able to send new emails via the application later, we need to add permission for Office Exchange. To do this, go to the "Manage" section in the application. There you will find the "API Permissions" where you can add the permission and later the administrator can also approve it.
Here we select "SMTP.SendAsApp". This permission is sufficient for sending. This permission must then be confirmed by your administrator for the platform; otherwise, your user will not have permission when logging in and will not be able to send emails.
Registration
Next, the application must be registered as a Service Principal. You can find the following instructions from Microsoft. This must be performed by an Azure administrator and is usually done via a console. The various steps are described in the documentation. Without this service principal, the application will lack permissions, and you will receive various error messages when sending.
ABAP Environment
Once the basic configuration in Azure is complete, we can return to the ABAP Environment to configure our settings.
Communication System
First, we create a new Communication System to connect to Entra. We then enter our SMTP server in the upper section. Here it's important that you use the correct port: not 443 as in the old one, but 587, in order to be able to send emails.
In the OAuth settings, we then need to configure the client settings. Here it's important that we define the authorization endpoint and the token endpoint. These are required to obtain a login token and to establish the session via OAuth.
In the OAuth settings, we then need to configure the client settings. Here it's important that we define the authorization endpoint and the token endpoint. These are needed to obtain a login token and to establish the session via OAuth.
login.microsoftonline.com/<DIRECTORY-ID>/oauth2/v2.0/token
login.microsoftonline.com/<DIRECTORY-ID>/oauth2/v2.0/authorize
Our configuration is not yet complete. In the next step, we need to decide which authentication method we want to use. Accordingly, we should create our outbound user and can then save the Communication System.
Method A - Basic
The first method is based on a similar concept to Basic Authentication. Here, we use the Client ID and a Client Secret to log in to the service. To do this, we create a new outbound user, select the authentication method OAuth 2.0, and choose Client Authentication Basic. We use the Application ID from our application as the Client ID. We define the client secret in the next step via the Azure platform.
In Azure, we switch to our application and find Certificates & Secrets in the Manage section. There, we can select Client Secrets and create a new client secret. This is like a password, which we can then enter in the configuration. Normally, the client secret we create here also has a limited lifespan, which we define during creation and which, depending on the settings in your Azure account, can be unlimited or limited.
Method B - JWT
In the second variant, we select JWT (JSON Web Token) as the client authentication method and enter the application ID as the client ID. However, before we can create the user, we must download the certificate using the "Download Certificate" button. Download the certificate to then make it available in Azure.
Next step, we go back to our application in Azure and find the Certificates section under Certificates & Secrets in the Manage area. Here, we need to upload the certificate we just downloaded so that the login can be completed. No password is required for this process; the validity period depends on the certificate and its duration.
Communication Arrangement
We should now have defined a communication system with the corresponding login. In the next step, we either create a new Communication Arrangement or adapt our existing one for the SAP_COM_0548 scenario. In the Additional Properties, we then specify the email address we use to log in. This is usually also the email address we will later use to send emails. Under Outbound Communication, we select the user we created, along with the corresponding authentication method we want to use.
After selecting the method, we then need to define the Additional Scope in the lower section. This is important for obtaining the appropriate authorizations after logging in and for interacting with the application. Here you will find the snippet to insert into the scope. Pressing ENTER should accept this.
https://outlook.office365.com/.default
Finally, you should check the arrangement and the login settings again in this section. The correct port, 587, must be entered here. If, for example, you have modified the old Communication Arrangement and it still shows 443, you will get error messages that are not necessarily self-explanatory.
Conclusion
Switching to OAuth 2.0 is more of a must-have and should be addressed to ensure communication via Azure and to continue using your email login. Several steps are necessary to complete the configuration, especially on Azure. Registering the permissions and the service principal can be somewhat more difficult depending on the organization and the account structure.
Further information:
Microsoft - Exchange Online Integration
Microsoft - Register Service Principal










