Skip to main content

Server Authentication with Bot Token Endpoint

This is the preferred method of authentication. It ends up being the simplest and most flexible choice for most provisional account integrations.
Use the Bot Token Endpoint if your game has an account system which uniquely identifies users. You pass your account system’s unique ID for the user, and Discord returns an access token — creating a provisional account for that identity if one does not already exist. No identity provider configuration is required for this method. If you have a hard requirement for a turnkey OIDC integration, see External Credentials Exchange; if you don’t have a backend, see Public Client Integration.
Your bot token is a privileged secret — it must stay on your backend and never ship in the game client. The client receives only the provisional access_token your backend returns. See How the Integration Fits Together for the full flow.

Server: Create the Provisional Token

Your backend exchanges the player’s identity for a Discord access token. Keep this call and your bot token on the server, exposed to the client through your own authenticated endpoint:

Bot Token Endpoint Response

Client: Connect With the Token

The game client receives the access_token from your backend — it never sees the bot token — and passes it straight to the SDK. Set your application ID, call Client::UpdateToken with the token as a Bearer token, then Client::Connect:

How the Integration Fits Together

Because your bot token never reaches the client, the client can’t call Discord’s bot token endpoint directly. Instead, your server brokers the request:
  1. The player signs in with your own account system, as they normally would.
  2. The game client asks your backend for a Discord provisional token.
  3. Your backend calls Discord’s /partner-sdk/token/bot endpoint — authenticated with your bot token — passing the player’s external_user_id (and optional preferred_global_name), and returns the resulting access_token to the client.
  4. The client hands that token to the SDK with Client::UpdateToken and calls Client::Connect.
Once authentication is complete, you can use the access token as you would a full Discord user’s access token. See Managing Provisional Accounts for token refresh, storage, and display names.

Error Handling

Common error codes and solutions when creating a provisional account:

Next Steps

Managing Provisional Accounts

Refresh access tokens and set display names.

Merging Accounts

Merge a provisional account into a full Discord account.

Unmerging Accounts

Sever the link between a Discord account and a provisional account.
Need help? Join the Discord Developers Server and share questions in the #social-sdk-dev-help channel for support from the community. If you encounter a bug while working with the Social SDK, please report it here: https://dis.gd/social-sdk-bug-report

Change Log