This guide is aimed at your firm’s IT administration and describes setting up MSAL authentication in the Azure portal, so that DEPLAW can receive email via IMAP and send email via SMTP. For IMAP/SMTP, Microsoft now only supports authentication via MSAL (OAuth2) – classic sign-in with a username and password is no longer available.

The screenshots show the actual setup in the Azure portal of Legal Data Technology GmbH; the tenant ID, client ID, and other IDs have been redacted.

Background: MSAL and “on-behalf-of”

The Microsoft Authentication Library (MSAL) handles the OAuth2 process against the Microsoft authentication interface. DEPLAW uses the on-behalf-of flow for this: the backend acts as its own service, exchanges the user’s token for its own token from the Microsoft identity platform, and afterward mainly uses that token (cached in the database).

Access to IMAP/SMTP happens from the perspective of the signed-in person – only mailboxes that person has permissions for can be accessed.

Overview: two app registrations

In the Azure portal (available at https://portal.azure.com/), you create two enterprise applications (app registrations):

1. DEPLAW MSAL AnmeldemaskeEnables sign-in via Microsoft Login (frontend).
2. DEPLAW KommunikationsschnittstelleProvides access to IMAP and SMTP (backend service).

Accessing the app registrations

In the Azure portal, use the search to navigate to Microsoft Entra ID:

Azure portal search for “Entra” with the result Microsoft Entra ID
In the Azure portal, search for "Entra" and open Microsoft Entra ID.

Then, under Manage → App registrations → New registration, create each application:

App registrations overview in Microsoft Entra ID with the New registration button
App registrations: New registration opens the form for a new application.

1. Application: DEPLAW MSAL Anmeldemaske

Registration

Set the following values when creating it:

Field Value
Name DEPLAW MSAL Anmeldemaske
Supported account types Single tenant
Redirect URI Platform Single-page application (SPA), value https://app.dep.law
Register an application form with name DEPLAW MSAL Anmeldemaske, account type Single tenant, and redirect URI Single-page application https://app.dep.law
The sign-in app's registration form with name, account type, and redirect URI.

Entering the data into the DEPLAW wizard

Once the first application is created, its data can already be entered into the DEPLAW wizard – under Settings → Communication → Microsoft Accounts → Microsoft Tenants → Add:

DEPLAW settings: Communication → Microsoft Accounts, with Microsoft Tenants and Microsoft Accounts tables, both empty, and an Add button
DEPLAW settings: Communication → Microsoft Accounts – this is where tenants and accounts are created.

The required values are shown in the enterprise application’s overview:

Overview of the DEPLAW MSAL Anmeldemaske app with Application (client) ID, Object ID, and Directory (tenant) ID, values redacted
Sign-in app overview: the **Application (client) ID** and **Directory (tenant) ID** are what you need.
Value Source
Tenant https://login.microsoftonline.com/{Directory (tenant) ID}/
Client Id corresponds to the application’s Application (client) ID

Enter these values in the wizard step Client MSAL Infos:

DEPLAW dialog Add Microsoft Tenant, step Client MSAL Infos, with Tenant and Client Id fields
Wizard step Client MSAL Infos: enter the tenant URL and client ID from the sign-in app.

2. Application: DEPLAW Kommunikationsschnittstelle

This second application governs access to IMAP and SMTP.

Registration

Field Value
Name DEPLAW Kommunikationsschnittstelle
Supported account types Single tenant
Register an application form with name DEPLAW Kommunikationsschnittstelle and account type Single tenant – Legal Data Technology GmbH
Registration form for the communications interface application.

Setting API permissions

Under API permissions → Add a permission, configure the IMAP and SMTP permissions:

API permissions for the communications interface, with an Add a permission button
Starting point: API permissions → Add a permission.

a) IMAP.AccessAsUser.All (Microsoft Graph) – select the Microsoft Graph API:

Request API permissions, selecting the Microsoft Graph API under Commonly used Microsoft APIs
Select the Microsoft Graph API.

Choose type Delegated permissions, select and add the permission IMAP.AccessAsUser.All:

Selecting delegated permissions, with IMAP.AccessAsUser.All checked
Delegated permission IMAP.AccessAsUser.All – read/write access to mailboxes via IMAP.

b) Mail.Send (Microsoft Graph) – type Delegated permissions, select and add the permission Mail.Send:

Selecting delegated permissions, with Mail.Send checked
Delegated permission Mail.Send – send emails as the signed-in user.

c) IMAP.AccessAsApp (Office 365 Exchange Online) – under the APIs my organization uses tab, filter for Office and select Office 365 Exchange Online:

APIs my organization uses, filtered by Office, with Office 365 Exchange Online checked
Select Office 365 Exchange Online from your organization's own APIs.

Choose type Application permissions, select and add the permission IMAP.AccessAsApp:

Selecting application permissions, with IMAP.AccessAsApp checked, Admin consent required: Yes
Application permission IMAP.AccessAsApp – requires admin consent.

All permissions now appear in the overview. Use Grant admin consent for “…” to give consent (the application permission IMAP.AccessAsApp requires this):

Configured permissions with a Grant admin consent for Legal Data Technology GmbH link, one row showing a warning icon
Grant admin consent – before consent, the application permission shows a warning icon.

Afterwards, the status should be green on every row:

Configured permissions, all four rows with a green checkmark Granted for Legal Data
All four permissions with a green "Granted for …" status.

Exposing an API

Finally, under Expose an API, set the application ID URI (api://{Client ID}):

Expose an API, with the Application ID URI field showing the suggested value api://Client-ID, client ID redacted
Accept the application ID URI in the format api://{Client ID}.

Use Add a scope to create the scope:

Field Value
Scope name deplaw.communications
Who can consent Admins and users
Admin consent display name / description DEPLAW Kommunikationsschnittstelle
State Enabled
Edit scope with scope name deplaw.communications, Who can consent set to Admins and users, admin consent display name and description DEPLAW Kommunikationsschnittstelle
Create the new scope deplaw.communications with "Admins and users".

The created scope then appears in the list:

Expose an API, list of Scopes defined by this API with the created scope deplaw.communications, Who can consent set to Admins only, State Enabled
The scope deplaw.communications is created and enabled.

Entering the remaining data into the DEPLAW wizard

In the wizard step Client MSAL Infos (continuing from application 1), fill in the OnBehalf Api Scope field – it corresponds to the newly created API, e.g. api://3c1bbe23XXXX/deplaw.communications:

Client MSAL Infos dialog with Tenant, Client Id, and OnBehalf Api Scope, all values redacted
Add the OnBehalf Api Scope in the wizard step Client MSAL Infos.

On the next wizard page, Api MSAL Infos (On Behalf of):

Field Value
Systemname your choice
Api Client Id corresponds to the Application (client) ID of the second application (DEPLAW Kommunikationsschnittstelle)

The application (client) ID is shown in the second application’s overview:

Overview of the DEPLAW Kommunikationsschnittstelle app with Application (client) ID and application ID URI, values redacted
Communications interface overview: take the **Application (client) ID** for the wizard.

Creating a client secret

For the Api Client Secret (backend service secret), create a client secret in the DEPLAW Kommunikationsschnittstelle app: Certificates & secrets → Client secrets → New client secret.

Field Value
Description e.g. DEPLAW
Expires e.g. Recommended: 180 days (6 months)
Certificates & secrets, Client secrets tab, New client secret dialog with description DEPLAW and expiry Recommended 180 days
Create a new client secret with a description and expiry period.

Completing the wizard

Enter the copied value as the Api Client Secret in the wizard step Api MSAL Infos (On Behalf of) and save via Finish:

Api MSAL Infos (On Behalf of), with fields Systemname DEPLAW, Api Client Id, and Api Client Secret masked as dots, Finish button
Enter the system name, Api Client Id, and the copied Api Client Secret, then click Finish.

3. Adding the scope in the sign-in app as a permission

So that the frontend (the DEPLAW MSAL Anmeldemaske app) can request a token for the backend service in the on-behalf-of flow, the scope deplaw.communications of the DEPLAW Kommunikationsschnittstelle app must be added as an API permission in the sign-in app.

In the DEPLAW MSAL Anmeldemaske app, under API permissions → Add a permission → APIs my organization uses, filter for deplaw and select DEPLAW Kommunikationsschnittstelle:

API permissions of the sign-in app, APIs my organization uses filtered by deplaw, DEPLAW Kommunikationsschnittstelle checked
In the sign-in app, filter for the DEPLAW Kommunikationsschnittstelle API by deplaw and select it.

Choose type Delegated permissions, select and add the scope deplaw.communications:

Request API permissions for DEPLAW Kommunikationsschnittstelle, Delegated permissions, scope deplaw.communications checked
Add the delegated permission deplaw.communications to the sign-in app.

Adding Microsoft Accounts in DEPLAW

Once the tenant configuration is complete, you can set up as many accounts as you like in DEPLAW – under Settings → Communication → Microsoft Accounts → Microsoft Accounts → Add:

  1. Select a tenant

    Select the tenant created earlier (e.g. DEPLAW).

  2. Sign in with Microsoft

    This button lets the respective user authenticate directly with Microsoft.

  3. Name / description

    Your choice (e.g. Testuser).

Add Microsoft Account dialog with Tenants DEPLAW, a Sign in with Microsoft button, name and description Testuser
Add Microsoft Account: select a tenant, sign in with Microsoft, and assign a name/description.

Summary of the values to enter

DEPLAW wizard field Source
Tenant https://login.microsoftonline.com/{Directory (tenant) ID}/
Client Id (Frontend) Application (client) ID of the DEPLAW MSAL Anmeldemaske app
OnBehalf API Scope api://{Client ID}/deplaw.communications of the DEPLAW Kommunikationsschnittstelle app
Systemname your choice
Api Client Id Application (client) ID of the DEPLAW Kommunikationsschnittstelle app
Api Client Secret Client secret of the DEPLAW Kommunikationsschnittstelle app (limited validity)