ahlan hamad

Setup guide · Microsoft 365 · Coming soon

Set up Microsoft 365: SharePoint filing and Microsoft accounts, step by step

This guide is for two people working together: your Microsoft 365 admin, who registers the Azure app and grants its permissions, and a company admin in AhlanHamad, who connects it. One app serves both parts: SharePoint document filing and Microsoft Entra ID accounts. Follow it in order. Every AhlanHamad label below is the one you will see on screen.

Updated 12 October 2026

1. Before you start

Coming soon. You can register the app and connect Microsoft 365 today. Filing documents in SharePoint, and disabling or creating Microsoft accounts, stay switched off until we switch them on for your company; until then the Microsoft 365 page shows only the connection.

CheckWhat you need
Where it standsBuilt, and tested only against simulated Microsoft Graph calls. It hasn't run in a real Microsoft 365 tenant yet, so when we switch it on for you, watch the first uploads and account changes on the Activity tabs.
Microsoft 365Your organisation's Microsoft 365 with SharePoint Online.
A Microsoft adminSomeone who can register apps in the Microsoft Entra admin center, and an admin who can grant consent. Granting consent for Microsoft Graph application permissions (section 5) needs a Privileged Role Administrator or Global Administrator (Microsoft Learn).
The person who signs inDocuments are uploaded as the Microsoft 365 account that connects. Use an account that can add files to the SharePoint library you will choose, and that your IT team keeps.
In AhlanHamadA company admin who can manage settings.

Never deleted. AhlanHamad never deletes a Microsoft account or a SharePoint file. A leaver's account is disabled and signed out; deleting it, and deciding what happens to its mailbox and OneDrive, stays with you in the Microsoft Entra admin center.

2. In Microsoft Entra: register your app

Sign in to the Microsoft Entra admin center (Microsoft Learn: register an application).

  1. Go to Entra ID → App registrations → New registration.
  2. Name: for example AhlanHamad HR. Supported account types: Single tenant only (your own organisation). Click Register.
  3. On the app's Overview, copy the Application (client) ID and the Directory (tenant) ID. You paste both into AhlanHamad (find your tenant ID).
  4. Add the redirect URI: Manage → Authentication → Add Redirect URI → Web, enter https://ahlanhamad.com/auth/microsoft-365/callback exactly as written, and click Configure (Microsoft Learn: add a redirect URI). Older screens show this as Add a platform → Web.
  5. Create the secret: Certificates & secrets → Client secrets → New client secret, add a description, pick an expiry (Microsoft allows at most 24 months) and click Add. Copy the Value straight away: Microsoft never shows it again (Microsoft Learn: add credentials). Note the expiry date in your calendar: when it passes, the connection stops until you enter a new secret.

3. Give the app its SharePoint permissions

  1. In the app, open API permissions → Add a permission → Microsoft Graph → Delegated permissions.
  2. Tick Sites.ReadWrite.All and Files.ReadWrite.All, and under OpenId permissions offline_access, openid and profile. Click Add permissions.
  3. Click Grant admin consent for <your organisation> and confirm, so nobody is asked to consent alone and the Status shows Granted (Microsoft Learn: grant admin consent).
Permission (delegated)Why AhlanHamad asks for it
Sites.ReadWrite.AllListing your sites and document libraries so you can pick one, and creating the employee folders in it.
Files.ReadWrite.AllUploading the documents you switch on. Sending one again replaces the file instead of making a copy.
offline_access, openid, profileKeeping the connection working after the sign-in, without asking you to sign in again each time.

These are delegated permissions: AhlanHamad acts as the person who signed in and can reach only what that person can. Microsoft doesn't require admin consent for these two by default, but many organisations stop users from consenting to apps (user consent settings); granting admin consent here avoids that. If the person who connected leaves, SharePoint uploads pause until someone reconnects.

4. In AhlanHamad: connect Microsoft 365

  1. Go to Integrations and open Microsoft 365 / SharePoint. The card is called Microsoft 365 Connection.
  2. Client ID: the Application (client) ID. Client Secret: the secret's Value from section 2.
  3. Azure AD Tenant ID: the Directory (tenant) ID from section 2.
  4. SharePoint Host: the start of your SharePoint address, for example company.sharepoint.com (open SharePoint in the browser and copy the part before the first /).
  5. SharePoint Site ID (optional): leave it empty. Once document filing is switched on you pick the site and library from a list.
  6. Check that the address under Redirect URI to register on your app is the one on your Azure app.
  7. Click Connect to Microsoft 365. AhlanHamad says “Azure AD OAuth initiated — complete sign-in to authorize access” and opens Microsoft.
  8. Sign in with the account from section 1 and accept the permissions.
  9. You come back to a page that says Connected to Microsoft 365, then to the Microsoft 365 page, where the card says Connected to Microsoft 365 / SharePoint with your SharePoint Host and Azure AD Tenant ID.

Your app's ID and secret stay saved. If you connect again later, the card says “Your app credentials are saved. Click Connect to sign in with them — no need to enter them again.” To use a new secret, click Replace credentials.

5. Microsoft accounts: the application permission (once switched on)

When we switch Microsoft account changes on, a Microsoft accounts (Entra ID) section appears under the connection, with the tabs Permission, Settings, Link existing users and Activity. Account changes use the same Azure app, but as itself (an application permission), not as the person who connected, so they keep working after that person leaves.

  1. In the Microsoft Entra admin center, open Entra ID → App registrations → your app.
  2. API permissions → Add a permission → Microsoft Graph → Application permissions → User.ReadWrite.All → Add permissions.
  3. Recommended: add User.RevokeSessions.All (application) the same way. Microsoft lists only this application permission for ending a user's sign-in sessions (Microsoft Learn: revokeSignInSessions); without it the account is still disabled, but sessions already open aren't ended at once.
  4. Optional: add Domain.Read.All (application) so AhlanHamad can list your verified domains. Without it, you type the domain.
  5. A Privileged Role Administrator or Global Administrator clicks Grant admin consent for <your organisation> and confirms. The Status must show Granted.
  6. Back in AhlanHamad, press Test connection on the Permission tab. “The app works — waiting account changes will resume” means it works; the page shows what Microsoft granted under What the last test saw.

Highlighted permissions on the Permission tab (such as Directory.ReadWrite.All) give the app more than account changes need. You can remove them; nothing in AhlanHamad depends on them.

6. SharePoint filing (once switched on)

  1. When we switch document filing on, the page gets the tabs Connection, Document push and Activity.
  2. On Document push, click Load sites, choose the Site and the Document library. Use a library only HR can open: files take the library's permissions.
  3. Check the Folder template (by default a folder per employee, with a sub-folder per type) and the preview under it.
  4. Under What to push, switch on the types you want: Employment contracts, HR letters, Employee documents, Offer letters. Click Save.
  5. Payslips are separate: switching Push payslips to SharePoint on asks you to confirm (“Send payslips to SharePoint?”), because salary figures then live in your SharePoint.

7. Troubleshooting

What you seeWhat to do
Enter your app's Client ID and Client Secret to connect.Paste both values from your Azure app, then click Connect to Microsoft 365.
Fill in the tenant and environment details above to connect.Fill in Azure AD Tenant ID and SharePoint Host.
Microsoft shows an error mentioning the redirect URI (for example AADSTS50011)The app's redirect URI doesn't match. Set it to https://ahlanhamad.com/auth/microsoft-365/callback under Authentication → Web (section 2), then connect again.
Microsoft asks for “Need admin approval”Your organisation doesn't let users consent. An admin clicks Grant admin consent for the app (section 3), then you connect again.
Couldn't connect Microsoft 365 — with “Token exchange failed: …”Microsoft refused to hand over the connection: usually the Client Secret is wrong or expired, or the redirect URI doesn't match exactly. Check both, then connect again.
SharePoint uploads are pausedMicrosoft refused the delegated connection, usually because the person who connected left or their consent was withdrawn. Reconnect Microsoft 365, or press Test connection once it is fixed.
Microsoft account changes are pausedMicrosoft refused the app: usually the client secret expired or admin consent was removed. Fix it in the Entra admin center (enter a new secret with Replace credentials if it expired), then press Test connection.
The app has no admin-consented User.ReadWrite.All application permission …Add User.ReadWrite.All as an application permission (not delegated) and click Grant admin consent (section 5).

8. Disconnecting

  1. In AhlanHamad, go to Integrations → Microsoft 365 / SharePoint and click Disconnect Microsoft 365. AhlanHamad deletes the stored secret and sign-in, and makes no more uploads or account changes.
  2. AhlanHamad cannot withdraw anything at Microsoft for you. To close the door completely, delete the client secret (or the whole app registration) in the Microsoft Entra admin center.

Microsoft sources used in this guide

About AhlanHamad × Microsoft 365· All integrations