> **Building with AI coding agents?** If you're using an AI coding agent, install the official Scalekit plugin. It gives your agent full awareness of the Scalekit API — reducing hallucinations and enabling faster, more accurate code generation.
>
> - **Claude Code**: `/plugin marketplace add scalekit-inc/claude-code-authstack` then `/plugin install <auth-type>@scalekit-auth-stack`
> - **GitHub Copilot CLI**: `copilot plugin marketplace add scalekit-inc/github-copilot-authstack` then `copilot plugin install <auth-type>@scalekit-auth-stack`
> - **Codex**: run the bash installer, restart, then open Plugin Directory and enable `<auth-type>`
> - **Skills CLI** (Windsurf, Cline, 40+ agents): `npx skills add scalekit-inc/skills --list` then `--skill <skill-name>`
>
> `<auth-type>` / `<skill-name>`: `agentkit`, `full-stack-auth`, `mcp-auth`, `modular-sso`, `modular-scim` — [Full setup guide](https://docs.scalekit.com/dev-kit/build-with-ai/)

---

# Discord

**Authentication:** OAuth 2.0
**Categories:** Communication
## What you can do

Connect this agent connector to let your agent:

- **Get get** — Retrieves a PNG image widget for a Discord guild
- **List list** — Lists the current user's guilds, returning partial data (id, name, icon, owner, permissions, features) for each
- **Invite resolve** — Resolves and retrieves information about a Discord invite code, including the associated guild, channel, event, and inviter
- **Connections retrieve user** — Retrieves a list of the authenticated user's connected third-party accounts on Discord, such as Twitch, YouTube, GitHub, Steam, and others

## Authentication

This connector uses **OAuth 2.0**. Scalekit acts as the OAuth client: it redirects your user to Discord, obtains an access token, and automatically refreshes it before it expires. Your agent code never handles tokens directly — you only pass a `connectionName` and a user `identifier`.

You supply your Discord **Connected App** credentials (Client ID + Secret) once per environment in the Scalekit dashboard.

Before calling this connector from your code, create the Discord connection in **AgentKit** > **Connections** and copy the exact **Connection name** from that connection into your code. The value in code must match the dashboard exactly.

## Set up the connector

Register your Scalekit environment with the Discord connector so Scalekit handles the OAuth 2.0 (PKCE) flow and token lifecycle for you. The connection name you create will be used to identify and invoke the connection programmatically.

1. ### Create a Discord application

    - Go to the [Discord Developer Portal](https://discord.com/developers/applications) and sign in with your Discord account.

    - Click **New Application**, enter a name for your app (e.g., `My Agent`), accept the terms, and click **Create**.

2. ### Set up the OAuth2 redirect URI

    - In [Scalekit dashboard](https://app.scalekit.com), go to **AgentKit** > **Connections** > **Create Connection**. Find **Discord** and click **Create**. Copy the redirect URI shown — it looks like:

      `https:///sso/v1/oauth//callback`

      > Image: Screenshot

    - Back in the Discord Developer Portal, open your application and go to **OAuth2** in the left sidebar.

    - Under **Redirects**, click **Add Redirect**, paste the URI from Scalekit, and click **Save Changes**.

      > Image: Screenshot

    > caution: Redirect URI must match exactly
>
> Discord performs an exact string match on the redirect URI. Any mismatch — including a trailing slash — will cause the OAuth flow to fail with an `invalid_redirect_uri` error.

3. ### Copy your credentials

    - On the **OAuth2** page, copy the **Client ID**.

    - Click **Reset Secret** to generate a **Client Secret** and copy it immediately. It will not be shown again.

4. ### Add credentials in Scalekit

    - In [Scalekit dashboard](https://app.scalekit.com), go to **AgentKit** > **Connections** and open the connection you created.

    - Enter the credentials you copied:
      - **Client ID**
      - **Client Secret**
      - **Scopes** — select the scopes your agent needs. Common scopes:

        | Scope | What it grants |
        | --- | --- |
        | `identify` | Read basic user profile (username, avatar, discriminator) |
        | `email` | Read the user's email address |
        | `guilds` | List the guilds the user belongs to |
        | `guilds.members.read` | Read the user's member data within a guild |
        | `connections` | Read third-party accounts linked to the user's Discord profile |
        | `openid` | Use Discord as an OpenID Connect provider |
        | `applications.entitlements` | Read premium entitlements for your application |

      > Image: Screenshot

    - Click **Save**.

    > tip: Request only the scopes you need
>
> Discord displays a consent screen listing every requested scope. Requesting unnecessary scopes reduces user trust and may cause authorization to be denied.

## Code examples

Connect a user's Discord account and make API calls on their behalf — Scalekit handles OAuth 2.0 (PKCE), token storage, and refresh automatically.

## Proxy API Calls

  ### Node.js

```typescript

const connectionName = 'discord'; // get your connection name from connection configurations
const identifier = 'user_123';    // your unique user identifier

// Get your credentials from app.scalekit.com → Developers → Settings → API Credentials
const scalekit = new ScalekitClient(
  process.env.SCALEKIT_ENV_URL,
  process.env.SCALEKIT_CLIENT_ID,
  process.env.SCALEKIT_CLIENT_SECRET
);
const actions = scalekit.actions;

// Authenticate the user — send this link to your user
const { link } = await actions.getAuthorizationLink({
  connectionName,
  identifier,
});
console.log('🔗 Authorize Discord:', link);
process.stdout.write('Press Enter after authorizing...');
await new Promise(r => process.stdin.once('data', r));

// Fetch the authenticated user's Discord profile via Scalekit proxy
const user = await actions.request({
  connectionName,
  identifier,
  path: '/api/users/@me',
  method: 'GET',
});
console.log(user);
```

  ### Python

```python

from dotenv import load_dotenv
load_dotenv()

connection_name = "discord"  # get your connection name from connection configurations
identifier = "user_123"      # your unique user identifier

# Get your credentials from app.scalekit.com → Developers → Settings → API Credentials
scalekit_client = scalekit.client.ScalekitClient(
    client_id=os.getenv("SCALEKIT_CLIENT_ID"),
    client_secret=os.getenv("SCALEKIT_CLIENT_SECRET"),
    env_url=os.getenv("SCALEKIT_ENV_URL"),
)
actions = scalekit_client.actions

# Authenticate the user — present this link to your user
link_response = actions.get_authorization_link(
    connection_name=connection_name,
    identifier=identifier
)
print("🔗 Authorize Discord:", link_response.link)
input("Press Enter after authorizing...")

# Fetch the authenticated user's Discord profile via Scalekit proxy
user = actions.request(
    connection_name=connection_name,
    identifier=identifier,
    path="/api/users/@me",
    method="GET"
)
print(user)
```

## Tool list

Use the exact tool names from the **Tool list** below when you call `execute_tool`. If you're not sure which name to use, list the tools available for the current user first.

## Tool list

### `discord_get_current_user_application_entitlements`

Retrieves entitlements for the current user for a given application. Use when you need to check what premium offerings or subscriptions the authenticated user has access to. Requires the applications.entitlements OAuth2 scope.

Parameters:

- `application_id` (`string`, required): The ID of the application to retrieve entitlements for.
- `exclude_deleted` (`boolean`, optional): Whether to exclude deleted entitlements.
- `exclude_ended` (`boolean`, optional): Whether to exclude ended entitlements.
- `limit` (`integer`, optional): Maximum number of entitlements to return (1–100).

### `discord_get_gateway`

Retrieves a valid WebSocket (wss) URL for establishing a Gateway connection to Discord. Use when you need to connect to the Discord Gateway for real-time events. No authentication required.

### `discord_get_guild_template`

Retrieves information about a Discord guild template using its unique template code. Use when you need to get details about a guild template for creating new servers.

Parameters:

- `template_code` (`string`, required): The unique code of the guild template.

### `discord_get_guild_widget`

Retrieves the guild widget in JSON format. Returns public information about a Discord guild's widget including online member count and invite URL. The widget must be enabled in the guild's server settings.

Parameters:

- `guild_id` (`string`, required): The ID of the Discord guild (server) to retrieve the widget for.

### `discord_get_guild_widget_png`

Retrieves a PNG image widget for a Discord guild. Returns a visual representation of the guild widget that can be embedded on external websites. The widget must be enabled in the guild's server settings.

Parameters:

- `guild_id` (`string`, required): The ID of the Discord guild (server) to retrieve the widget image for.
- `style` (`string`, optional): Style of the widget image.

### `discord_get_invite_deprecated`

DEPRECATED: Use discord_resolve_invite instead. Retrieves information about a specific invite code including guild and channel details. This endpoint is deprecated — prefer the Resolve Invite tool for new integrations.

Parameters:

- `invite_code` (`string`, required): The unique invite code to look up.
- `with_counts` (`boolean`, optional): Whether to include approximate member and presence counts.
- `with_expiration` (`boolean`, optional): Whether to include the expiration date of the invite.

### `discord_get_my_guild_member`

Retrieves the guild member object for the currently authenticated user within a specified guild, provided they are a member of that guild. Requires the guilds.members.read OAuth2 scope.

Parameters:

- `guild_id` (`string`, required): The ID of the guild to retrieve the current user's member object from.

### `discord_get_my_oauth2_authorization`

Retrieves current OAuth2 authorization details for the application, including app info, granted scopes, token expiration date, and user data (contingent on scopes like 'identify'). Useful for verifying what access the current token has.

### `discord_get_my_user`

Fetches comprehensive profile information for the currently authenticated Discord user, including username, avatar, discriminator, locale, and email if the 'email' OAuth2 scope is granted.

### `discord_get_openid_connect_userinfo`

Retrieves OpenID Connect compliant user information for the authenticated user. Returns standardized OIDC claims (sub, email, nickname, picture, locale, etc.) following the OpenID Connect specification. Requires an OAuth2 access token with the 'openid' scope; additional fields require 'identify' and 'email' scopes.

### `discord_get_public_keys`

Retrieves Discord OAuth2 public keys (JWKS). Use when you need to verify OAuth2 tokens or access public keys for cryptographic operations such as signature verification.

### `discord_get_user`

Retrieve information about a Discord user. With OAuth Bearer token, use '@me' as user_id to return the authenticated user's information. With a Bot token, you can query any user by their ID. Returns username, avatar, discriminator, locale, premium status, and email (if email scope is granted).

Parameters:

- `user_id` (`string`, required): The ID of the user to retrieve. Use '@me' to get the authenticated user's information.

### `discord_list_my_guilds`

Lists the current user's guilds, returning partial data (id, name, icon, owner, permissions, features) for each. Primarily used for displaying server lists or verifying guild memberships. Requires the 'guilds' OAuth2 scope.

Parameters:

- `after` (`string`, optional): Get guilds after this guild ID (for pagination).
- `before` (`string`, optional): Get guilds before this guild ID (for pagination).
- `limit` (`integer`, optional): Maximum number of guilds to return (1–200, default 200).
- `with_counts` (`boolean`, optional): Whether to include approximate member and presence counts for each guild.

### `discord_list_sticker_packs`

Retrieves all available Discord Nitro sticker packs. Returns official Discord sticker packs including pack name, description, stickers, cover sticker, and banner asset.

### `discord_resolve_invite`

Resolves and retrieves information about a Discord invite code, including the associated guild, channel, event, and inviter. Prefer this over the deprecated Get Invite tool for new integrations.

Parameters:

- `invite_code` (`string`, required): The unique invite code to resolve.
- `guild_scheduled_event_id` (`string`, optional): Guild scheduled event ID to include event details in the response.
- `with_counts` (`boolean`, optional): Whether to include approximate member and presence counts.
- `with_expiration` (`boolean`, optional): Whether to include the expiration date of the invite.

### `discord_retrieve_user_connections`

Retrieves a list of the authenticated user's connected third-party accounts on Discord, such as Twitch, YouTube, GitHub, Steam, and others. Requires the 'connections' OAuth2 scope.


---

## More Scalekit documentation

| Resource | What it contains | When to use it |
|----------|-----------------|----------------|
| [/llms.txt](/llms.txt) | Structured index with routing hints per product area | Start here — find which documentation set covers your topic before loading full content |
| [/llms-full.txt](/llms-full.txt) | Complete documentation for all Scalekit products in one file | Use when you need exhaustive context across multiple products or when the topic spans several areas |
| [sitemap-0.xml](https://docs.scalekit.com/sitemap-0.xml) | Full URL list of every documentation page | Use to discover specific page URLs you can fetch for targeted, page-level answers |
