OnedriveApp
This is a library of Google Apps Script for using Microsoft OneDrive.
AI Summary
OnedriveApp
A wrapper library that allows Google Apps Script to access Microsoft Graph API for managing OneDrive files and Outlook emails.
Target Users
Intermediate or advanced GAS developers who need to automate internal workflows that integrate OneDrive and Outlook.
Problems Solved
Without the library, developers must hand-code OAuth2 flows and REST calls to Microsoft services, which is cumbersome.
Tags
Main Features
Simplified OAuth2 handling
Retrieve and persist access/refresh tokens with a single call after setting client_id and client_secret.
Comprehensive OneDrive file operations
Listing, creating, deleting, downloading and uploading (resumable 10 MB chunks) of files/folders are all available from GAS.
Inter-conversion with Google Drive
Upload from Google Drive to OneDrive or download the reverse, with optional Google↔Microsoft document conversion.
Batch email operations
Get, send, reply, forward and delete emails via batch requests for efficient Outlook automation.
Easy installation
Start by adding the Script ID; no extra Google Cloud configuration is required.
Usage Examples
Retrieve OneDrive file list and log it
/**
* Sample that fetches the file list of the OneDrive root folder
* and prints it to the execution log.
* clientId, clientSecret and refreshToken must already be saved
* in Script Properties.
*/
function listOnedriveRootFiles() {
// Load stored OAuth2 credentials
const prop = PropertiesService.getScriptProperties();
// Initialize the library
const odapp = OnedriveApp.init(prop);
// Get list of files/folders in root (no args => root)
const files = odapp.getFilelist();
// Output the result
console.log(JSON.stringify(files, null, 2));
}
Copy and run the code to see a JSON list of items in the OneDrive root, verifying that the MS Graph integration works.