Document number | Revision |
---|---|
DOCU13517 | 1 |
OAuth Registration for Microsoft 365 / Azure ADBackgroundIntroductionPrerequisitesGuidesRegister your applicationSet up client secret (application password)Add app permissionsAdd mailbox access permissionsCommon Issues
This Document describes the process of adding and configuring OAuth for Microsoft 365 within Azure
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.
AccessAsApp
⇒ check IMAP.AccessAsApp
and/or POP.AccessAsApp
⇒ click [Add permissions].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].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].AzureAD
and ExchangeOnlineManagement
modules.
Open your PowerShell as Administrator, and run:Install-Module -Name AzureAD
Install-Module -Name ExchangeOnlineManagement
Confirm installation from PSGallery by typing Y + Enter.
(Wondering why these modules install from an untrusted repository? See this answer to Azure-PowerShell issue.)
x$AppId = "YOUR_APP_ID_HERE"
$TenantId = "YOUR_TENANT_ID_HERE"
Import-module AzureAD
Connect-AzureAd -Tenant $TenantId
($Principal = Get-AzureADServicePrincipal -filter "AppId eq '$AppId'")
$PrincipalId = $Principal.ObjectId
xxxxxxxxxx
$DisplayName = "Some principal name for IMAP/POP3 here"
Import-module ExchangeOnlineManagement
Connect-ExchangeOnline -Organization $TenantId
New-ServicePrincipal -AppId $AppId -ServiceId $PrincipalId -DisplayName $DisplayName
xxxxxxxxxx
Add-MailboxPermission -User $PrincipalId -AccessRights FullAccess -Identity "mailbox.1@example.org"
Add-MailboxPermission -User $PrincipalId -AccessRights FullAccess -Identity "mailbox.2@example.org"
Add-MailboxPermission -User $PrincipalId -AccessRights FullAccess -Identity "mailbox.3@example.org"
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.