> ## 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 Discord OAuth App

> Complete guide to creating and configuring a Discord OAuth application

## Prerequisites

* Discord account
* Access to Discord Developer Portal

## Step 1: Create Discord Developer Account

1. Visit [https://discord.com/developers](https://discord.com/developers)
2. Click **"Get Started"** or **"Login"** if you already have an account
3. Sign in with your Discord account or create a new developer account

<img src="https://mintcdn.com/klavisai/-iSbcEKcAuQ3FbzH/images/knowledge-base/discord_oauth_app/discord_step1_login.png?fit=max&auto=format&n=-iSbcEKcAuQ3FbzH&q=85&s=86a11e47e9f1ac3e0cac00084fd8c0c5" alt="Discord Developer Login" width="1920" height="1080" data-path="images/knowledge-base/discord_oauth_app/discord_step1_login.png" />

## Step 2: Create a New App

1. Once logged in, go to **"Applications"** in your developer dashboard
2. Click **"New Application"** to create a new app

<img src="https://mintcdn.com/klavisai/-iSbcEKcAuQ3FbzH/images/knowledge-base/discord_oauth_app/discord_step2_create_new_app.png?fit=max&auto=format&n=-iSbcEKcAuQ3FbzH&q=85&s=0a2a6c3d561407fca5baf592047b2a09" alt="Create New Application" width="1920" height="1080" data-path="images/knowledge-base/discord_oauth_app/discord_step2_create_new_app.png" />

3. Click on the **"App"** that you just created
4. Go to **"General Information"** section
5. Fill in the app details:
   * **App name**: Your application name (e.g., your brand name)
   * **App description**: Your application description
   * **"App Icon"**: Upload 100x100px PNG (recommended)
   * **"Tags"**: Add tags that describe your application
   * **Privacy policy URL**: Your privacy policy URL
   * **Terms of service URL**: Your terms of service URL

<img src="https://mintcdn.com/klavisai/-iSbcEKcAuQ3FbzH/images/knowledge-base/discord_oauth_app/discord_step3_app_info.png?fit=max&auto=format&n=-iSbcEKcAuQ3FbzH&q=85&s=eb817dc41e6a3052ab6d0813a05d5d04" alt="General App Information" width="1920" height="1080" data-path="images/knowledge-base/discord_oauth_app/discord_step3_app_info.png" />

## Step 3: Build A Bot

1. Go to **"Bot"** section.
2. Get **Discord Token**:

* Click on **Reset Token** button under **TOKEN** tab
* Enter your **Discord Password** and press **Submit**
* New **Token** has been generated
* **Copy** this token (keep it secure!)

<img src="https://mintcdn.com/klavisai/-iSbcEKcAuQ3FbzH/images/knowledge-base/discord_oauth_app/discord_step4_get_discord_token.png?fit=max&auto=format&n=-iSbcEKcAuQ3FbzH&q=85&s=3d1e53d6a6d9d6f216d7d2c52d6274f6" alt="Generate Discord Token" width="1920" height="1080" data-path="images/knowledge-base/discord_oauth_app/discord_step4_get_discord_token.png" />

3. Set **Bot Permissions**:

* Choose **Administrator** under **General Permissions** (recommended)

<img src="https://mintcdn.com/klavisai/-iSbcEKcAuQ3FbzH/images/knowledge-base/discord_oauth_app/discord_step5_bot_permissions.png?fit=max&auto=format&n=-iSbcEKcAuQ3FbzH&q=85&s=8328bdd499779f4bd6f6434d925c8359" alt="Setting Bot Permissions" width="1920" height="1080" data-path="images/knowledge-base/discord_oauth_app/discord_step5_bot_permissions.png" />

<Note>
  Klavis AI recommends to select required OAuth scopes only.
</Note>

## Step 4: Configure OAuth Settings

Navigate to **"OAuth2"**:

* **Client ID**: Copy this value
* **Client Secret**: Generate and copy this value (keep it secure!)
* **Redirect URI**: Set as **[https://api.klavis.ai/oauth/discord/callback](https://api.klavis.ai/oauth/discord/callback)**

<img src="https://mintcdn.com/klavisai/-iSbcEKcAuQ3FbzH/images/knowledge-base/discord_oauth_app/discord_step6_oauth_settings.png?fit=max&auto=format&n=-iSbcEKcAuQ3FbzH&q=85&s=aaee27467ac8810a5c70e4952f40b00b" alt="Configure OAuth Settings" width="1920" height="1080" data-path="images/knowledge-base/discord_oauth_app/discord_step6_oauth_settings.png" />

<Note>
  Normally, the redirect URI should be set to: `https://api.klavis.ai/oauth/discord/callback`
</Note>

## Step 5: OAuth2 URL Generator

1. Scroll to **Scopes**

* Select **bot** from the scopes list
* For **Bot Permissions**: select **Administrator**

<img src="https://mintcdn.com/klavisai/-iSbcEKcAuQ3FbzH/images/knowledge-base/discord_oauth_app/discord_step7_oauth2_url_generator.png?fit=max&auto=format&n=-iSbcEKcAuQ3FbzH&q=85&s=fee237aa6b3bd6897a33b5407c2ab816" alt="OAuth2 URL Generator" width="1080" height="1080" data-path="images/knowledge-base/discord_oauth_app/discord_step7_oauth2_url_generator.png" />

2. Generate URL:

* Integration Type: **Guild Install** (recommended)
* Copy **Generated URL** and paste in browser to complete authentication

<img src="https://mintcdn.com/klavisai/-iSbcEKcAuQ3FbzH/images/knowledge-base/discord_oauth_app/discord_step8_generate_oauth_url.png?fit=max&auto=format&n=-iSbcEKcAuQ3FbzH&q=85&s=955b60105541e8a1be42858f1f7fb03f" alt="Generate OAuth2 URL and paste in browser" width="1352" height="298" data-path="images/knowledge-base/discord_oauth_app/discord_step8_generate_oauth_url.png" />

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

## (Optional) Step 6: 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 Discord 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 Discord **Client ID** and **Client Secret** from Step 4
3. **Set Redirect URI**: Use `https://api.klavis.ai/oauth/discord/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 Discord OAuth with white-label
     const authUrl = `https://api.klavis.ai/oauth/discord/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 Discord OAuth with white-label
     const oauthUrl = await klavis.mcpServer.getOAuthUrl({
       serverName: Klavis.McpServerName.Discord,
       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 Discord OAuth with white-label
     oauth_url = klavis.mcp_server.get_oauth_url(
         server_name=McpServerName.Discord,
         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

* [Discord Developer Documentation](https://discord.com/developers/docs/intro/)
* [Discord OAuth 2.0 Authentication Guide](https://discord.com/developers/docs/topics/oauth2)
* [Discord API Scopes Reference](https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes)
* [Klavis OAuth & White Labeling Guide](/auth/white-label)
* [Klavis White Label Dashboard](https://www.klavis.ai/home/white-label)
