Document numberRevision
DOCU135171

OAuth Registration for Microsoft 365 / Azure AD

 

Background

This Document describes the process of adding and configuring OAuth for Microsoft 365 within Azure

Introduction

This document describes a way of settings up an App registration for use with Highstage. However, this might not be the only way of doing this. There might also be special constraints within the tenant or for a specific server that influence how this should be set up. So this guide should only be seen as guidance.

Prerequisites

Guides

Register your application

  1. In Azure Portal ⇒ expand the left menu ⇒ select Azure Active Directory ⇒ select App registrations ⇒ click + New registration. (Azure Portal is constantly evolving, so if you cannot find this page, use the search bar.)

Screenshot Sample 1

  1. Name your application, choose which kind of accounts are going to use it, and click [Register]. Note: This guide is suitable for single tenant account types. For other types, further steps might be different.

Screenshot Sample 2

  1. You successfully registered your application and you can view its associated IDs. Some of them will be needed later to obtain an OAuth 2.0 token.

Screenshot Sample 3

Set up client secret (application password)

  1. In the left menu, select Certificates & secrets ⇒ click + New client secret.

Screenshot Sample 4

  1. Provide some description for this secret, choose expiration period, and click Add.

Screenshot Sample 5

  1. Immediately copy and save the newly created client secret's Value (not Secret ID). You will not be able to view the Value later anymore.

Screenshot Sample 6

Add app permissions

  1. In the left menu, select API permissions ⇒ click + Add a permission.

Screenshot Sample 7

  1. Navigate to APIs my organization uses tab ⇒ type Office/Microsoft 365 Exchange in the search bar ⇒ click Office/Microsoft 365 Exchange Online entry.

Screenshot Sample 8

  1. Click Application permissions ⇒ type AccessAsApp ⇒ check IMAP.AccessAsApp and/or POP.AccessAsApp ⇒ click [Add permissions].

Screenshot Sample 9

  1. The newly-added IMAP.AccessAsApp and POP.AccessAsApp permissions have to be approved by your organization's administrator. Ask them to grant consent to your application by clicking Grant admin consent for [organization].

Screenshot Sample 10

  1. Application permissions have been granted. Optionally, you can remove the delegated User.Read permission which is not needed for app-only application - click the context menu on the right side of the permission and select [Remove permission].

Screenshot Sample 11

Add mailbox access permissions

  1. Now, you have to assign access permissions for your mailboxes. There is no web UI for this yet - you have to use PowerShell.
  2. Install the required PowerShell modules. Note: You can skip this step if you have already installed AzureAD and ExchangeOnlineManagement modules. Open your PowerShell as Administrator, and run:

Confirm installation from PSGallery by typing Y + Enter.

Screenshot Sample 12

(Wondering why these modules install from an untrusted repository? See this answer to Azure-PowerShell issue.)

Screenshot Sample 13

  1. Register the service principal for your application. Note: You will be asked to log into your Exchange Online account.

Screenshot Sample 14

  1. Add FullAccess mailbox permissions to all mailboxes you want to access from your application.
  1. Congratulations! Now you have registered an application for accessing Office/Microsoft 365 mailboxes via IMAP or POP3 protocol and received its Application (client) ID, Client secret and Directory (tenant) ID.

These strings are going to be used by your application to authenticate to Microsoft 365 via OAuth 2.0 and receive an OAuth token. This token is then used to authenticate to Exchange Online using IMAP or POP3 protocols.

Common Issues

 


highstage_footer