> ## 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**

<img src="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" alt="OneDrive App Registration Form" width="1302" height="609" data-path="images/knowledge-base/onedrive_oauth_app/onedrive_step1_register.png" />

## 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`
</Note>

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

<img src="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" alt="Graph API Permissions" width="1302" height="609" data-path="images/knowledge-base/onedrive_oauth_app/onedrive_step2_scopes.png" />

## 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**

<img src="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" alt="Client ID" width="1302" height="609" data-path="images/knowledge-base/onedrive_oauth_app/onedrive_step3_clientID.png" />

<img src="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" alt="Secret" width="1302" height="609" data-path="images/knowledge-base/onedrive_oauth_app/onedrive_step3_secret.png" />

<Check>
  You have successfully created a OneDrive OAuth application! You now have your Client ID and Client Secret ready for integration with Klavis AI.
</Check>

## (Optional) Step 4: White Labeling

<Note>
  White labeling allows you to customize the OAuth experience with your own branding instead of Klavis AI's.
</Note>

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:

   <CodeGroup>
     ```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)
     ```
   </CodeGroup>

<Tip>
  For detailed white labeling implementation and code examples, see our [OAuth & White Labeling guide](/auth/white-label).
</Tip>

## 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](/auth/white-label)
* [Klavis White Label Dashboard](https://www.klavis.ai/home/white-label)
