> ## Documentation Index
> Fetch the complete documentation index at: https://www.klavis.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Setting Up OneDrive OAuth App

> Complete guide to creating and configuring a OneDrive OAuth application

## Prerequisites

* Microsoft account (personal or organizational)
* Access to [Azure Portal](https://portal.azure.com/)

## Step 1: Create Microsoft App Registration

1. Visit [https://portal.azure.com/](https://portal.azure.com/) and sign in
2. Search **App registrations** → click **New registration**
3. Fill out the form:

   * **Name**: Choose a descriptive app name
   * **Supported account types**: Select **Accounts in any organizational directory and personal Microsoft accounts**
   * **Redirect URI**: `https://api.klavis.ai/oauth/onedrive/callback`
4. Click **Register**

![OneDrive App Registration Form](https://mintcdn.com/klavisai/TEzGHGg1v0ZnLKee/images/knowledge-base/onedrive_oauth_app/onedrive_step1_register.png?fit=max\&auto=format\&n=TEzGHGg1v0ZnLKee\&q=85\&s=a824294a1cbedf3476a3991a6f50e054)

## Step 2: Configure API Permissions

> [!NOTE]
>
> Klavis OneDrive MCP Server uses the following OAuth scopes:`openid, profile, email, offline_access, Files.ReadWrite.All, User.Read`

1. Go to your app → **API Permissions**
2. Click **Add a permission** → **Microsoft Graph** → **Delegated permissions**
3. Select:

   * `openid`, `profile`, `email`, `offline_access`
   * `Files.ReadWrite.All`
   * `User.Read`
4. Click **Add permissions**
5. (Optional) Click **Grant admin consent** if you want to approve for all org users

![Graph API Permissions](https://mintcdn.com/klavisai/TEzGHGg1v0ZnLKee/images/knowledge-base/onedrive_oauth_app/onedrive_step2_scopes.png?fit=max\&auto=format\&n=TEzGHGg1v0ZnLKee\&q=85\&s=0e8bec9059cfc473437b7d2779a1b600)

## Step 3: Collect Client ID & Secret

1. Go to **Certificates & Secrets** tab
2. Click **New client secret** → set description + expiry → **Add**
3. Copy the **Client Secret Value** (shown only once)
4. From **Overview** tab, copy **Application (client) ID**

![Client ID](https://mintcdn.com/klavisai/TEzGHGg1v0ZnLKee/images/knowledge-base/onedrive_oauth_app/onedrive_step3_clientID.png?fit=max\&auto=format\&n=TEzGHGg1v0ZnLKee\&q=85\&s=90ef2894ef4852a96623f6104fde236a)

![Secret](https://mintcdn.com/klavisai/TEzGHGg1v0ZnLKee/images/knowledge-base/onedrive_oauth_app/onedrive_step3_secret.png?fit=max\&auto=format\&n=TEzGHGg1v0ZnLKee\&q=85\&s=0df0e34bc001eca2b453b5e1c1705f9c)

> [!TIP]
>
> You have successfully created a OneDrive OAuth application! You now have your Client ID and Client Secret ready for integration with Klavis AI.

## (Optional) Step 4: White Labeling

> [!NOTE]
>
> White labeling allows you to customize the OAuth experience with your own branding instead of Klavis AI's.

If you want to use your own OneDrive OAuth application with custom branding:

1. **Configure White Labeling**: Go to [https://www.klavis.ai/home/white-label](https://www.klavis.ai/home/white-label)
2. **Add Your Credentials**: Enter your OneDrive **Client ID** and **Client Secret** from Step 3
3. **Set Redirect URI**: Use `https://api.klavis.ai/oauth/onedrive/callback` or your custom callback URL
4. **Initiate OAuth**: Use your client ID when starting the OAuth flow:

   ```javascript without SDK theme={null}
   // Example: Initiating OneDrive OAuth with white-label
   const authUrl = `https://api.klavis.ai/oauth/onedrive/authorize?instance_id=${instanceId}&client_id=${yourClientId}`;
   window.location.href = authUrl;
   ```

   ```typescript TypeScript SDK theme={null}
   import { Klavis } from "@klavis/sdk";

   const klavis = new Klavis({
     apiKey: "YOUR_API_KEY"
   });

   // Example: Initiating OneDrive OAuth with white-label
   const oauthUrl = await klavis.mcpServer.getOAuthUrl({
     serverName: Klavis.McpServerName.Onedrive,
     instanceId: instanceId,
     clientId: yourClientId,
     // redirectUri: YOUR_REDIRECT_URI,
     // scope: "YOUR_SCOPES", 
   });

   window.location.href = oauthUrl;
   ```

   ```python Python SDK theme={null}
   import webbrowser
   from klavis import Klavis
   from klavis.types import McpServerName

   klavis = Klavis(api_key="YOUR_API_KEY")

   # Example: Initiating OneDrive OAuth with white-label
   oauth_url = klavis.mcp_server.get_oauth_url(
       server_name=McpServerName.ONEDRIVE,
       instance_id=instance_id,
       client_id=your_client_id,
       # redirect_uri="YOUR_REDIRECT_URI",
       # scope="YOUR_SCOPES"
   )

   # Open OAuth URL in user's default browser
   webbrowser.open(oauth_url)
   ```

> [!TIP]
>
> For detailed white labeling implementation and code examples, see our [OAuth & White Labeling guide](https://www.klavis.ai/docs/auth/white-label.md).

## Resources

* [Microsoft Identity Platform Docs](https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow)
* [Microsoft Graph API – OneDrive](https://learn.microsoft.com/en-us/graph/onedrive-concept-overview)
* [Klavis OAuth & White Labeling Guide](https://www.klavis.ai/docs/auth/white-label.md)
* [Klavis White Label Dashboard](https://www.klavis.ai/home/white-label)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.