Microsoft 365 Setup
Create an Azure AD application for Microsoft 365 APIs including Outlook Mail, Calendar, OneDrive, Contacts, Teams, and SharePoint.
Setup Steps
Section titled “Setup Steps”-
Access Azure Portal
Go to the Azure Portal and sign in with your Microsoft 365 admin account.
-
Register New Application
Navigate to Azure Active Directory → App registrations → New registration:
- Name: Fp Switchboard
- Supported account types: Accounts in any organizational directory and personal Microsoft accounts
- Click “Register”
-
Add Redirect URI
Under Authentication, add a Web platform with the redirect URI:
https://api.switchboard.fpdigital.ai/oauth/microsoft365/callback -
Configure API Permissions
Go to API permissions → Add permission → Microsoft Graph → Delegated permissions. Add these scopes:
User.ReadMail.ReadMail.ReadWriteMail.SendCalendars.ReadCalendars.ReadWriteFiles.ReadFiles.ReadWriteContacts.ReadContacts.ReadWritePeople.ReadTeam.ReadBasic.AllChannel.ReadBasic.AllChannelMessage.Read.AllChannelMessage.SendChat.ReadWriteChatMessage.ReadChatMessage.SendOnlineMeetings.ReadWriteSites.Read.AllSites.ReadWrite.Alloffline_access -
Grant Admin Consent
Click “Grant admin consent for [your organization]” if you want all users to use the app without individual consent.
-
Create Client Secret
Go to Certificates & secrets → New client secret:
- Create a secret with your preferred expiration
- Copy the Value immediately (it won’t be shown again)
-
Copy Application Details
From the Overview page, copy the Application (client) ID.
Environment Variables
Section titled “Environment Variables”npx wrangler secret put MICROSOFT_CLIENT_IDnpx wrangler secret put MICROSOFT_CLIENT_SECRET| Variable | Description |
|---|---|
MICROSOFT_CLIENT_ID | Application (client) ID from Azure AD |
MICROSOFT_CLIENT_SECRET | Client secret value from Certificates & secrets |
Redirect URI
Section titled “Redirect URI”https://api.switchboard.fpdigital.ai/oauth/microsoft365/callbackTeams & SharePoint
Section titled “Teams & SharePoint”Teams and SharePoint use the same Azure AD app credentials. No additional setup is needed - the scopes listed above include Teams and SharePoint permissions.
Important Notes
Section titled “Important Notes”- Access tokens expire after 1 hour
- Refresh tokens are long-lived and automatically used
- Multi-tenant apps can authenticate users from any Azure AD tenant
- Personal Microsoft accounts are also supported with some API limitations