The following Oracle documentation describes the basic procedure: https://docs.oracle.com/en/middleware/soa-suite/integration-adapters/12.2.1.4/develop-soa-adapters/oracle-jca-adapter-ums.html#TKADP-GUID-0CAAD2F7-915A-447C-A444-24CA490CB58F
However, that procedure has a fundamental catch: "The O365 refresh token regularly expires every 30 to 90 days. Upon expiration, you will need to generate a new token and update the email driver."
Luckily, Oracle has created a (brand new) way better way to solve this by providing standard client credentials/secrets that have a longer validity. That is described in SOA Suite UMS With Office 365 - Refresh Token (Doc ID 3028460.1)
To use this approach, you have to:
Create and authorize an Azure App similar to what is described in "Configuring Oracle Workflow for OAuth 2.0 in Oracle E-Business Suite Release 12.2 and Release 12.1.3 (Doc ID 2884072.1". Go for the chapter 4 in particular; but create a client secret instead of a key there.
Apply the patch 35773019
While SOA Suite is still down backup and modify "the end" of /opt/soadev/Oracle_Home/user_projects/domains/soadev_domain/config/fmwconfig/usermessagingconfig.xml as follows (this is just for IMAP, for SMTP it works similarly):
<ns1:Property name="ProcessingChunkSize" value="100"/>
<ns1:Property name="ImapAuthPlainDisable" value="false"/>
<ns1:Property name="ImapAuthUseOAuth2" value="true"/>
<ns1:Property name="OAuth2AccessTokenSupplierFactory" value="oracle.sdpinternal.messaging.oauth.ums.ms.UMSO365AccessTokenSupplierFactory"/>
<ns1:Property name="O365OAuthClientID" value="944ca635-1482-4522-9f00-e88ac39c4624"/>
<ns1:Property name="O365OAuthTenantID" value="55d1ba91-f485-4cc3-ad12-6d7c3a3f05d3"/>
<ns1:Property name="O365OAuthRefreshTokenScope" value=""/>
<ns1:Property name="O365OAuthRefreshToken" value=""/>
<ns1:Property name="O365OAuthClientSecret" value="sfdgsdfg~sdfhwtwergdfsgfdsghsdhdfghgadf"/>
<ns1:Property name="O365OAuthClientSecretScope" value="https://outlook.office365.com/.default"/>
Then you can start up SOA Suite again.