> For the complete documentation index, see [llms.txt](https://docs.workflowgen.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.workflowgen.com/azure/10.6/exchange-online-microsoft-graph-for-remote-approval.md).

# Exchange Online: Microsoft Graph for Remote Approval

## Overview

As of WorkflowGen 10.5, Remote Approval can use Microsoft Graph to receive and process approval emails from an Exchange Online mailbox.

This procedure uses OAuth 2.0 with a client secret and limits the application's access to one dedicated mailbox. First, register an application in Microsoft Entra ID; then, grant mailbox access in Exchange Online and configure WorkflowGen.

## Prerequisites

* WorkflowGen 10.5 or later installed, with **Exchange Online - Microsoft Graph** available in the Remote Approval mail server types.
* WorkflowGen administrator access as well as access to stop and start the WorkflowGen Engine Service.
* A dedicated Exchange Online mailbox in Microsoft 365 Global Cloud. Record its primary email address and its user principal name (UPN) or mailbox object ID.
* Permission to create a Microsoft Entra application and client secret.
* An Exchange administrator account authorized to create application role assignments. See Microsoft's [Application RBAC requirements](https://learn.microsoft.com/en-us/exchange/permissions-exo/application-rbac#requirements).
* A secured administrator workstation with PowerShell and connectivity to Exchange Online.
* Outbound HTTPS access from the WorkflowGen server to `login.microsoftonline.com` and `graph.microsoft.com`.

{% hint style="warning" %}
**Important:** Use a mailbox dedicated to Remote Approval. The service processes the entire Inbox and can delete messages. Run only one active Remote Approval listener for this mailbox.
{% endhint %}

## Microsoft Entra ID configuration

#### Step 1: Register a new application

1. Open the Microsoft Entra admin center.
2. On the **App registrations** page, click **New registration**.
3. Enter the following properties:
   * **Name:** `WorkflowGen Remote Approval`
   * **Supported account types:** Accounts in this organizational directory only (single tenant)
   * **Redirect URI:** Leave this blank
4. Click **Register**.
5. On the **Overview page,** record the **Application (client) ID** and **Directory (tenant) ID**.

#### Step 2: Generate a client secret

1. In the app registration, open **Certificates & secrets**.
2. Under **Client secrets**, click **New client secret**.
3. Enter a description, such as `WorkflowGen Remote Approval`, and choose an expiration date.
4. Click **Add**.
5. Copy the secret **Value** (not the **Secret ID**) immediately and store it securely. You'll enter this value in WorkflowGen later.\
   ⚠️ **Important:** The value cannot be retrieved after you leave the page. Never include it in screenshots or documentation.

#### Step 3: Record the enterprise application Object ID

1. Under **Entra ID**, click **Enterprise applications**, then open the **All applications** page.
2. Find the application you created in step 1. Check its **Application ID** if multiple applications have the same name.
3. Open its **Overview** and copy the **Object ID**.\
   ✏️ **Note:** Use this value in the Exchange Online commans below, not the **Object ID** shown under **App registrations,** which identifies a different object.

### Review the registration

You should now have the following:

* Application (client) ID
* Directory (tenant) ID
* Client secret value
* Enterprise application Object ID

{% hint style="warning" %}
Mailbox permissions are assigned in Exchange Online in the next section. **Do not add the Microsoft Graph `Mail.ReadWrite` or `Mail.Send` application permissions under API permissions in Entra ID.** Tenant-wide Entra permissions and Exchange Application RBAC permissions are additive; a tenant-wide grant can bypass the mailbox restriction. See [Microsoft's explanation of combined permissions](https://learn.microsoft.com/en-us/exchange/permissions-exo/application-rbac).
{% endhint %}

## Exchange Online configuration

Run these commands in the same PowerShell session on your administrator workstation. This setup creates new objects for the new application; run the creation commands once.

#### Step 1: Connect to Exchange Online

1. Install the Exchange Online module if it is not already installed:

   ```powershell
   Install-Module -Name ExchangeOnlineManagement -Scope CurrentUser
   ```
2. Load the module and sign in with your Exchange administrator account:

   ```powershell
   Import-Module ExchangeOnlineManagement
   Connect-ExchangeOnline -UserPrincipalName "admin@contoso.com"
   ```
3. Set the values for your environment. Replace every example or placeholder:

   ```powershell
   $graphAppId = "<APPLICATION-CLIENT-ID>"
   $graphEnterpriseObjectId = "<ENTERPRISE-APPLICATION-OBJECT-ID>"
   $graphMailbox = "remoteapproval@contoso.com"
   $graphScopeName = "WorkflowGen Remote Approval Mailbox"
   ```

   Use the dedicated mailbox's **primary email address** for `$graphMailbox`.

For connection requirements, see the Microsoft [Connect to Exchange Online PowerShell](https://learn.microsoft.com/en-us/powershell/exchange/connect-to-exchange-online-powershell) article.

#### Step 2: Register the application in Exchange Online

Create the Exchange Online reference to the enterprise application:

```powershell
New-ServicePrincipal -AppId $graphAppId `
    -ObjectId $graphEnterpriseObjectId `
    -DisplayName "WorkflowGen Remote Approval"
```

See the Microsoft [New-ServicePrincipal](https://learn.microsoft.com/en-us/powershell/module/exchangepowershell/new-serviceprincipal?view=exchange-ps) reference for command parameters.

#### Step 3: Restrict access to the dedicated mailbox

1. Preview the mailbox selection:

   ```powershell
   $graphMailboxFilter = "EmailAddresses -eq 'smtp:$graphMailbox'"
   Get-Recipient -Filter $graphMailboxFilter |
       Format-Table DisplayName, PrimarySmtpAddress, RecipientTypeDetails
   ```
2. Confirm that the output contains **only the dedicated Remote Approval mailbox**. Correct the address before continuing if the result is empty or selects another recipient.
3. Create the mailbox scope:

   ```powershell
   New-ManagementScope -Name $graphScopeName `
       -RecipientRestrictionFilter $graphMailboxFilter
   ```

See the Microsoft [New-ManagementScope](https://learn.microsoft.com/en-us/powershell/module/exchangepowershell/new-managementscope?view=exchange-ps) reference for management scope options.

#### Step 4: Grant read, send, and delete access

Assign both roles to the application through the mailbox scope:

```powershell
New-ManagementRoleAssignment -Name "WorkflowGen Remote Approval ReadWrite" `
    -App $graphEnterpriseObjectId `
    -Role "Application Mail.ReadWrite" `
    -CustomResourceScope $graphScopeName

New-ManagementRoleAssignment -Name "WorkflowGen Remote Approval Send" `
    -App $graphEnterpriseObjectId `
    -Role "Application Mail.Send" `
    -CustomResourceScope $graphScopeName
```

`Application Mail.ReadWrite` allows reading and deleting approval replies. `Application Mail.Send` allows sending corrective messages. See the Microsoft [New-ManagementRoleAssignment](https://learn.microsoft.com/en-us/powershell/module/exchangepowershell/new-managementroleassignment?view=exchange-ps) reference for role assignment parameters.

#### Step 5: Verify mailbox access

1. Test the dedicated mailbox:

   ```powershell
   Test-ServicePrincipalAuthorization -Identity $graphEnterpriseObjectId `
       -Resource $graphMailbox |
       Format-Table RoleName, InScope
   ```
2. Confirm that the values of both the application `Mail.ReadWrite` and `Mail.Send` roles are set to `True` in the **InScope** column.

This command verifies Exchange RBAC assignments; it does not report separate Entra grants. See the Microsoft [Test-ServicePrincipalAuthorization](https://learn.microsoft.com/en-us/powershell/module/exchangepowershell/test-serviceprincipalauthorization?view=exchange-ps) reference for authorization test details.&#x20;

Allow **30 minutes to 2 hours** for permission changes to reach Graph before running the WorkflowGen connection test; the authorization test bypasses that cache. See the Microsoft [Application RBAC limitations](https://learn.microsoft.com/en-us/exchange/permissions-exo/application-rbac#limitations) article for permission propagation and caching limitations.

## WorkflowGen configuration

#### Step 1: Stop Remote Approval

1. On the **Configuration** panel **Remote Approval** tab, clear **Activate** and click **Save**.&#x20;
2. Stop every WorkflowGen Engine Service instance monitoring this mailbox and wait for any active polling to finish.

Keep Remote Approval disabled and the listeners stopped until the connection test succeeds.

#### Step 2: Configure the incoming mail server

In **Incoming mail server**, enter:

<table><thead><tr><th valign="top">Field</th><th valign="top">Value</th></tr></thead><tbody><tr><td valign="top">Type</td><td valign="top">Exchange Online - Microsoft Graph</td></tr><tr><td valign="top">Mailbox object ID or UPN</td><td valign="top">UPN or object ID of the dedicated mailbox</td></tr><tr><td valign="top">Default reply-to email</td><td valign="top">Primary email address of the dedicated mailbox</td></tr><tr><td valign="top">Application (client) ID</td><td valign="top">Application ID recorded in Entra ID</td></tr><tr><td valign="top">Client secret</td><td valign="top">Select <strong>Enter a new secret</strong> and paste the secret value</td></tr><tr><td valign="top">Scope</td><td valign="top"><code>https://graph.microsoft.com/.default</code></td></tr><tr><td valign="top">Access token URI</td><td valign="top"><code>https://login.microsoftonline.com/{tenant-id}/oauth2/v2.0/token</code></td></tr></tbody></table>

Replace `{tenant-id}` with the **Directory (tenant) ID**. The Graph scope is fixed. If a secret is already stored, select **Replace secret** to enter the new application's secret.

{% hint style="info" %}

* Server address, port, security, domain, and mailbox password are not used in Graph mode.
* If you use a reply-to alias, first send an email from an external mail system and confirm that it arrives in this exact mailbox.
  {% endhint %}

#### Step 3: Test the connection

1. Leave **Activate** cleared.
2. Click **Test Graph connection** before saving the new connector settings.
3. Wait for the success message.

The test uses the current form values to check authentication, Inbox access, message retrieval, sending, and deletion. It sends a test email to the mailbox and removes its verified Inbox copy. A copy remains in **Sent Items** and can be removed manually.

If the test fails, correct the settings and repeat it while the listeners remain stopped.

#### Step 4: Activate Remote Approval

1. Click **Save** to store the complete connector configuration.
2. Check **Activate** and click **Save** again.
3. Start **one** WorkflowGen Engine Service listener for this mailbox.
4. Reply to a test Remote Approval notification. Confirm that the action is processed and the reply is removed from the mailbox Inbox.

Remote Approval is now configured to use Microsoft Graph.

## Switching from EWS to Microsoft Graph

1. Disable Remote Approval, save, and stop all listeners for the mailbox.
2. Keep the existing EWS settings in a protected location if rollback is needed.
3. Complete the Entra and Exchange Online configuration above for the new app.
4. Enter all Graph settings, test the connection, save, and activate Remote Approval using the steps above.

EWS and Graph share one configuration profile. Review every required field when changing connectors. To return to EWS, enter its complete configuration again using the [EWS configuration guide](https://docs.workflowgen.com/azure/10.6/exchange-online-modern-authentication-for-remote-approval.md).

## Renewing the client secret

1. In the Microsoft Entra admin center, open **App registrations**, select your application, then go to the **Certificates & secrets** page and create a replacement secret before the current one expires.
2. Disable Remote Approval, save, and stop all listeners for the mailbox.
3. Select **Replace secret**, enter the new value, and test the connection.
4. Save, activate Remote Approval, and start one listener.
5. Confirm successful processing before deleting the previous secret.

## Troubleshooting

<table><thead><tr><th valign="top">Problem</th><th valign="top">What to check</th></tr></thead><tbody><tr><td valign="top">Authentication fails / <code>401</code></td><td valign="top">Tenant ID, client ID, secret <strong>Value</strong>, secret expiration, and token URI</td></tr><tr><td valign="top">Access denied / <code>403</code></td><td valign="top">Enterprise application Object ID, both Exchange roles, mailbox scope, and permission propagation</td></tr><tr><td valign="top">Test email is not received</td><td valign="top">Reply-to address and mail routing to the monitored mailbox</td></tr><tr><td valign="top">Corrective message cannot be sent / <code>413</code></td><td valign="top">An oversized message or send failure can leave the reply in the Inbox; stop the listener, resolve the request manually, and remove the retained reply before restarting</td></tr></tbody></table>

If processing, sending, or deletion fails, a retained reply can be processed again. Check the request status before handling it manually.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.workflowgen.com/azure/10.6/exchange-online-microsoft-graph-for-remote-approval.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
