# Microsoft OneDrive

Upload, download, copy, move, share and organize files and folders in OneDrive.

## Connect Microsoft OneDrive

1. In the sidebar, open **Connections** and press **Add connection**.
2. Type `microsoft onedrive` and choose **Microsoft OneDrive**.
3. Press **Sign in with Microsoft OneDrive**, then choose your account in Microsoft OneDrive’s window and allow access.

Before you sign in, the sheet asks:

- **Account type · Optional**: Which Microsoft accounts may sign in: common (work, school or personal; the default when empty), organizations (work or school only) or consumers (personal only). For your own app registered for one directory only (single tenant), its Directory (tenant) ID.

Microsoft OneDrive works with work, school and personal Microsoft accounts.

**What if it says “Microsoft OneDrive sign-in isn’t set up here”?**

Signing in with Microsoft OneDrive needs a Microsoft OneDrive app on this installation, and it has none yet.

**On Cloud:** The sheet says “It’s set up once for everyone who uses this service, not by an organization.”

**Self-hosted:** An admin of the installation sees **Set up Microsoft OneDrive sign-in** instead, and sets it up once for everyone. Everyone else sees who to ask.

1. Create an app in Microsoft OneDrive’s developer settings ([Microsoft OneDrive’s guide](https://learn.microsoft.com/entra/identity-platform/quickstart-register-app)).
2. In GoRunner, copy the **Redirect address to add in Microsoft OneDrive’s developer settings**, and add it to the app.
3. Paste the **Client ID** and **Client secret**, then press **Save and sign in**.

[Set up a sign-in app](https://docs.gorunner.io/self-host/oauth-apps#other-providers)

**Can I use my own Microsoft OneDrive app?**

Yes. In the sheet, open **Use your own Microsoft OneDrive app** and paste its **Client ID** and **Client secret**. Add the redirect address it shows to your app first. The connection then signs in through your app instead of the installation’s.

[Connections](https://docs.gorunner.io/build/connections) says how to sign in again, rename or delete it. In a product that embeds GoRunner, **Add connection** can be missing: then [your provider makes connections](https://docs.gorunner.io/embed/customer-connections) for you.

## Start a workflow

Add a trigger and choose **Microsoft OneDrive**. The trigger uses the same connection as the steps.

### On File or Folder Created or Changed

Checks OneDrive's list of changes about once a minute and starts a run for each file or folder created, or changed, since the check before. The first check after publishing only takes note of the time (it starts nothing); changing the trigger starts over the same way. A file that is created and then edited before the next check counts as created once. On a personal OneDrive each check reads the watched folder's whole list of changes (at most 10,000 items): watch a folder rather than the whole drive there.

- **Trigger on · Required**: Which changes start a run. Options: File created, File changed, Folder created, Folder changed. Default: File created.
- **Folder · Optional**: Watch only the items directly in this folder. Empty watches the whole OneDrive.

A later step can use its data, such as `{{trigger.change_type}}`, `{{trigger.createdDateTime}}`, `{{trigger.file}}` and 7 more. See [Use data from earlier steps](https://docs.gorunner.io/build/use-data-from-earlier-steps).

## Do things in Microsoft OneDrive

Add a **Microsoft OneDrive** step, choose a **Resource**, then an **Operation**. Choose a row to see its fields.

- [File](https://docs.gorunner.io/apps/microsoft-onedrive#fields-f-file): Upload · Download · Get · Copy · Move · Rename · Search · Share · Delete
- [Folder](https://docs.gorunner.io/apps/microsoft-onedrive#fields-f-folder): Create · Get Items · Move · Rename · Search · Share · Delete

Later steps read a step’s output by its name: see [Use data from earlier steps](https://docs.gorunner.io/build/use-data-from-earlier-steps).

## Limits

- A reply from Microsoft OneDrive can be up to 16 MB (a file download can have its own limit). A larger one fails the step; it is never cut short.
- When Microsoft OneDrive says to slow down (429), the step waits as long as it asks, if the step’s time allows. Otherwise it fails and says when to try again.

Not in your list? See [When an app isn’t here](https://docs.gorunner.io/apps/when-an-app-isnt-here#q-not-in-list).

## For developers

In the API, which calls apps pieces, Microsoft OneDrive is `pieceId: "microsoftonedrive"` with `actionId: "microsoftonedrive"`, set by `resource` and an `operation_…` field, such as `operation_file`. Its trigger is `onedrivetrigger` / `onedrive_poll`. [Get an app](https://docs.gorunner.io/api/apps/get-app) returns every field.

It can change something outside the run (`writes_external`). See [How versions and side effects work](https://docs.gorunner.io/apps#q-versions).

### Microsoft OneDrive › File

### Upload

- **Folder · Optional**: The folder the file goes into. Empty is the top of the OneDrive.
- **File Name · Optional**: The name to save it under, with its extension. Empty uses the uploaded file's own name.
- **Upload a File · Optional**: On: upload a file (from an earlier step or this form). Off: type the text the file holds. On by default.
- **File · Required**: Upload a file, or switch to an expression to use one from an earlier step (such as {{steps.download.result}}). Files over 4 MB are sent in parts. Shows when **Upload a File** is on.
- **Text · Required**: The text the file holds (saved as UTF-8). Shows when **Upload a File** is off.
- **If the Name Is Taken · Optional**: What to do when the folder already holds an item with this name. Options: Replace it, Keep both (add a number), Fail the step. Default: Replace it.

### Download, Get and Delete

- **File · Required**: The file.

### Copy and Move

- **File · Required**: The file.
- **Destination Folder · Optional**: Where the file goes. Empty is the top of the OneDrive.
- **New Name · Optional**: A name for the copy or the moved file. Empty keeps its name.

### Rename

- **File · Required**: The file.
- **New Name · Required**: The new name (a file's with its extension).

### Search

- **Search Text · Required**: Words in the file's name, or in a file's text and details (OneDrive's own search).
- **Return All · Optional**: Read every file, page by page (at most 2000; past that the step fails rather than stop early). Off by default.
- **Limit · Optional**: How many files to return (1–2000). Default: 50. Shows when **Return All** is off.

### Share

- **File · Required**: The file.
- **Link Type · Optional**: What people with the link may do. Options: View, Edit, Embed (personal accounts). Default: View.
- **Who Can Use It · Optional**: Anyone with the link, or only people in your organization (work and school accounts). Options: Anyone with the link, People in my organization. Default: Anyone with the link.
- **Password · Optional**: A password the link asks for (personal accounts only). Empty sets none.
- **Expires · Optional**: When the link stops working. Empty never expires (unless your organization's policy says otherwise).

### Microsoft OneDrive › Folder

### Create

- **Name · Required**: The new folder's name.
- **Parent Folder · Optional**: Where the new folder goes. Empty is the top of the OneDrive.
- **If the Name Is Taken · Optional**: What to do when the folder already holds an item with this name. Options: Replace it, Keep both (add a number), Fail the step. Default: Keep both (add a number).

### Get Items

- **Folder · Optional**: The folder whose items to list. Empty is the top of the OneDrive.
- **Return All · Optional**: Read every item, page by page (at most 2000; past that the step fails rather than stop early). Off by default.
- **Limit · Optional**: How many items to return (1–2000). Default: 50. Shows when **Return All** is off.

### Move

- **Folder · Required**: The folder.
- **Destination Folder · Optional**: Where the folder goes. Empty is the top of the OneDrive.

### Rename

- **Folder · Required**: The folder.
- **New Name · Required**: The new name (a file's with its extension).

### Search

- **Search Text · Required**: Words in the folder's name, or in a file's text and details (OneDrive's own search).
- **Return All · Optional**: Read every item, page by page (at most 2000; past that the step fails rather than stop early). Off by default.
- **Limit · Optional**: How many items to return (1–2000). Default: 50. Shows when **Return All** is off.

### Share

- **Folder · Required**: The folder.
- **Link Type · Optional**: What people with the link may do. Options: View, Edit, Embed (personal accounts). Default: View.
- **Who Can Use It · Optional**: Anyone with the link, or only people in your organization (work and school accounts). Options: Anyone with the link, People in my organization. Default: Anyone with the link.
- **Password · Optional**: A password the link asks for (personal accounts only). Empty sets none.
- **Expires · Optional**: When the link stops working. Empty never expires (unless your organization's policy says otherwise).

### Delete

- **Folder · Required**: The folder.

Source: https://docs.gorunner.io/apps/microsoft-onedrive
