Has anyone implemented a document management solution alongside Microsoft 365 or Google Workspace?
Loading
Has anyone implemented a document management solution alongside Microsoft 365 or Google Workspace?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Ajay BansodeRank #7,443 · 241 reputationPosted Aug 22, 2025, 7:38 AM EDT
1) Microsoft 365 (SharePoint/OneDrive) via Microsoft Graph
What this demo does
Authenticates app-only (daemon) with Azure AD
Uploads a file to a SharePoint Document Library folder
Writes metadata (columns) to the associated ListItem
Reads version history
Setup (once)
Register an app in Entra ID (Azure AD):
Authentication: Application (client credentials).
API permissions (Application):
Sites.ReadWrite.All,Files.ReadWrite.All(grant admin consent).Get: Tenant ID, Client ID, Client Secret.
Find your Site ID and Drive ID (document library). Easiest: open the library in SharePoint → Graph Explorer can reveal IDs, or use the
sites?search=endpoint once.NuGet
dotnet add package Azure.Identity dotnet add package Microsoft.GraphCode (Console app)
Notes
Create your custom columns in the document library first (same internal names used in
FieldValueSet).For approvals, wire a Power Automate flow to the library and trigger on create/update, or call a flow HTTP endpoint from C# (p zremium connector) to start approvals programmatically.
Ajay BansodeRank #7,443 · 241 reputationPosted Aug 22, 2025, 7:39 AM EDT
2) Google Workspace (Google Drive) via Drive API (.NET)
What this demo does
Authenticates with a service account using domain-wide delegation
Uploads a file to a Shared Drive / folder
Sets metadata (name, description, custom properties)
Shares the file (adds a permission)
Lists revisions (versions)
Setup (once)
Create a Google Cloud project → Enable Drive API.
Create a Service Account, download the JSON key.
In Google Workspace Admin, grant Domain-wide delegation to the SA for scope:
https://www.googleapis.com/auth/driveShare your target Shared Drive / folder with the service account or impersonate a user with access.
We’ll impersonate an admin/user via
UserEmailToImpersonate.NuGet
dotnet add package Google.Apis.Drive.v3 dotnet add package Google.Apis.AuthCode (Console app)
using Google.Apis.Auth.OAuth2; using Google.Apis.Drive.v3; using Google.Apis.Services; using Google.Apis.Upload; class GDriveDemo { // === Fill these === private const string ServiceAccountJsonPath = "C:\\keys\\my-sa.json"; private const string UserEmailToImpersonate = "[email protected]"; // has Drive access private const string ParentFolderId = "YOUR_FOLDER_OR_SHARED_DRIVE_FOLDER_ID"; static async Task Main() { var drive = await GetDriveService(); // 1) Upload with metadata + custom properties var fileMeta = new Google.Apis.Drive.v3.Data.File { Name = $"Invoice_{DateTime.UtcNow:yyyyMMddHHmmss}.pdf", Parents = new[] { ParentFolderId }, Description = "Invoice for Acme Corp", Properties = new Dictionary { { "InvoiceNumber", "INV-2025-00123" }, { "Customer", "Acme Corp" } } }; using var stream = new FileStream("C:\\temp\\sample.pdf", FileMode.Open, FileAccess.Read); var createReq = drive.Files.Create(fileMeta, stream, "application/pdf"); createReq.Fields = "id, name, webViewLink"; var progress = await createReq.UploadAsync(); if (progress.Status != UploadStatus.Completed) throw new Exception($"Upload failed: {progress.Exception}"); var created = createReq.ResponseBody!; Console.WriteLine($"Uploaded: {created.Name}, Id: {created.Id}, Link: {created.WebViewLink}"); // 2) Add a viewer permission to a user (external/internal) var perm = new Google.Apis.Drive.v3.Data.Permission { Type = "user", Role = "reader", EmailAddress = "[email protected]" }; var permReq = drive.Permissions.Create(perm, created.Id); permReq.SendNotificationEmail = false; await permReq.ExecuteAsync(); Console.WriteLine("Permission granted."); // 3) List revisions (versions) var revs = await drive.Revisions.List(created.Id).ExecuteAsync(); foreach (var r in revs.RevisionsValue ?? []) { Console.WriteLine($"Revision: {r.Id}, ModifiedTime: {r.ModifiedTime}"); } } static async Task GetDriveService() { var scopes = new[] { DriveService.Scope.Drive }; var sa = GoogleCredential.FromFile(ServiceAccountJsonPath) .CreateScoped(scopes) .CreateWithUser(UserEmailToImpersonate); return new DriveService(new BaseClientService.Initializer { HttpClientInitializer = sa, ApplicationName = "DMS Demo", }); } }Notes
Custom metadata on Drive is best stored in
properties(key/value). For robust schemas, keep a parallel DB (SQL) and store the Drive fileId there.If using Shared Drives, ensure the impersonated user has access to that drive and
supportsAllDrives=trueon certain calls (if needed).Choosing Between M365 & Google
Need tight records management, retention, Power Automate workflows → SharePoint/Graph is usually stronger.
Need cross-platform simple storage/sharing with lightweight metadata → Drive API is quick to wire up.