Skip to main content
Version: 0.2.3

Microsoft 365 Overview

Microsoft

Microsoft 365 Connectors

Sercha provides connectors for Microsoft 365 services: OneDrive, Outlook, and Calendar. All Microsoft connectors use OAuth 2.0 with PKCE for authentication, requiring you to create an app registration in the Azure Portal.

Available Connectors

ConnectorDescriptionDocumentation
OneDriveIndex files from OneDriveOneDrive Connector
OutlookIndex emails from OutlookOutlook Connector
CalendarIndex calendar eventsCalendar Connector
Account Types

Microsoft has different account types with varying permissions:

  • Personal accounts (outlook.com, hotmail.com): Full access to all services
  • Work/School accounts: May have restrictions based on organisation policies

If you encounter permission errors with a work account, contact your IT administrator or use a personal Microsoft account for testing.

OAuth Setup

All Microsoft connectors share the same OAuth client. You only need to create one app registration in Azure Portal.

Personal Account Setup

For personal Microsoft accounts, you can create an app registration that works with consumer accounts.

Create an Azure Account

If you don't have an Azure account:

  1. Go to Azure Portal
  2. Sign in with your Microsoft account (or create one)
  3. Azure offers free tier services for personal use

Create App Registration

  1. Go to Azure Portal
  2. Navigate to Microsoft Entra ID (formerly Azure Active Directory)
  3. Select App registrations from the left menu
  4. Click New registration

Configure App Registration

  1. Enter app details:
    • Name: Sercha (or your preferred name)
    • Supported account types: Select Accounts in any organizational directory and personal Microsoft accounts
    • Redirect URI: Select Web and enter http://localhost:18080/callback
  2. Click Register

Create Client Secret

  1. In your app registration, go to Certificates & secrets
  2. Click New client secret
  3. Enter a description (e.g., Sercha CLI)
  4. Select an expiration (recommended: 24 months)
  5. Click Add
  6. Copy the secret value immediately - it won't be shown again

Configure API Permissions

After creating the app registration, add the required API permissions.

  1. In your app registration, go to API permissions
  2. Click Add a permission
  3. Select Microsoft Graph
  4. Select Delegated permissions
  5. Add the following permissions:
PermissionPurpose
openidRequired for OAuth authentication
offline_accessRequired for refresh tokens
User.ReadRead user profile (for account identification)
Mail.ReadRead emails (Outlook connector)
Calendars.ReadRead calendar events (Calendar connector)
Files.ReadRead files (OneDrive connector)
  1. Click Add permissions
Minimal Permissions

You only need to add permissions for the connectors you plan to use:

  • OneDrive only: openid, offline_access, User.Read, Files.Read
  • Outlook only: openid, offline_access, User.Read, Mail.Read
  • Calendar only: openid, offline_access, User.Read, Calendars.Read

OAuth URLs

Sercha uses these OAuth endpoints for Microsoft authentication:

SettingValue
Authorization URLhttps://login.microsoftonline.com/common/oauth2/v2.0/authorize
Token URLhttps://login.microsoftonline.com/common/oauth2/v2.0/token
Callback URLhttp://localhost:18080/callback

Sercha runs a temporary local server on port 18080 to receive the OAuth callback during the authorisation flow.

Tenant-Specific URLs

For single-tenant (work/school only) apps, replace common with your tenant ID:

  • https://login.microsoftonline.com/{tenant-id}/oauth2/v2.0/authorize

Registering with Sercha

After creating your app registration, register it with Sercha:

sercha auth add \
--provider microsoft \
--name "My Microsoft Account" \
--client-id "YOUR_APPLICATION_CLIENT_ID" \
--client-secret "YOUR_CLIENT_SECRET"

Find your Application (client) ID on the app registration Overview page.

This will open your browser to complete the Microsoft authorisation flow. After authorising, you can create sources for OneDrive, Outlook, and Calendar using this authorisation.

Rate Limiting

Microsoft Graph APIs have per-user and per-app throttling limits. Sercha implements rate limiting to stay within these limits:

ServiceRate LimitBurst
OneDrive5 requests/second10
Outlook5 requests/second10
Calendar5 requests/second10

These are conservative defaults. Microsoft's actual limits vary based on the operation and your subscription tier.

Troubleshooting

Common Errors

ErrorCauseSolution
AADSTS50011Redirect URI mismatchVerify http://localhost:18080/callback is configured exactly
AADSTS65001Consent requiredGrant admin consent or enable user consent in Azure
AADSTS70011Invalid scopeCheck that API permissions are correctly configured
status 400Invalid requestVerify client ID and secret are correct

Redirect URI Requirements

The redirect URI must be configured exactly as:

http://localhost:18080/callback

Common mistakes:

  • Using https:// instead of http://
  • Missing /callback path
  • Wrong port number

References

Next